Support » Fixing WordPress » Require post title – prevent 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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)

    		var title = $('#title').val();
    		if( title.length == 0 || title.replace(/\s/g,'').length == 0 ){
    			$("<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");

    (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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Require post title – prevent posts with no title’ is closed to new replies.