All in One SEO Pack – Add title automatically

Adding the title autmatically can easily be done by making some small changes to your `functions.php` file.

<?php
/**
  * All in one SEO title and description autocomplete
  */
function aiosp_editor_title() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
 	var title = jQuery("#title"),
 		aiosp_title = jQuery('[name=aiosp_title]'),
 		val_title = title.val().replace(/^s+|s+$/gm,'') || '',
 		val_aiosp_title = aiosp_title.val().replace(/^s+|s+$/gm,'') || '';
 	 if (val_aiosp_title.length == 0 && val_title.length > 0) {
 		aiosp_title.val( val_title );
 	}
 	 title.keydown(function(){
 		if ( title.val().trim() == aiosp_title.val().trim() )
 		{
 			setTimeout(function () { 
				aiosp_title.val( title.val() );
 			}, 1);
 		}
 	});
});
</script>
<?php
}
add_action( 'admin_head-post.php', 'aiosp_editor_title');
add_action( 'admin_head-post-new.php', 'aiosp_editor_title');
?>Code language: HTML, XML (xml)