I'm sure there's a plugin or setting for this, but I just can't find it:
How do you require the authors to enter a title for a post?
I'm getting a lot of posts with no title.
I'm sure there's a plugin or setting for this, but I just can't find it:
How do you require the authors to enter a title for a post?
I'm getting a lot of posts with no title.
I have the same problem. It's odd that there's no setting or plug-in available to prevent it. Would love to hear of a solution.
If anyone's still interested, I was able to add this feature.
require-title.js (put in your theme directory)
jQuery(document).ready(function($){
$('#post').submit(function(event){
var title = $('#title').val();
if( title.length == 0 || title.replace(/\s/g,'').length == 0 ){
event.preventDefault();
$('div#notice').remove();
$("<div id='notice' class='error below-h2'><p>A title is required for all updates.</p></div>").insertAfter('h2');
alert("A title is required for all updates");
$('#title').focus();
$('#ajax-loading').hide();
$('#publish').removeClass('button-primary-disabled');
}
});
});
(I'm sure this javascript could be written more elegantly.) Then, add this to your theme's functions.php:
// Require post title
if ( is_admin() ) { wp_enqueue_script('require-post-title', get_bloginfo('template_directory') . '/require-title.js'); }
this will pop up an alert box and put a red box at the top of the new/edit post form if the title is left blank.
I tried your code, but still can publish un-titled posts.. Any ideas?
Thanks
This topic has been closed to new replies.