WordPress.org

Ready to get started?Download WordPress

Forums

Requie Title (4 posts)

  1. tophfro
    Member
    Posted 8 years ago #

    Hello, I need to require the title field in the write post section. I've searched the various plugin site and this forum but have not found anything. Does anyone know how i can do this?

  2. Mark Jaquith
    WordPress Lead Dev
    Posted 8 years ago #

    Try this:


    <?php
    /*
    Plugin Name: Require a Title
    */

    function require_title_for_posts($title='') {
    if ( '' == $title )
    die('You must provide a title! Press the "back" button in your browser to correct this.');

    return $title;
    }

    add_filter('title_save_pre', 'require_title_for_posts', 0);

    ?>

    1. Copy that text (starting with <?php and ending with ?>) into a new text file
    2. Save the text file as require-titles.php
    3. Upload this to your /wp-content/plugins/ directory
    4. Activate the plugin via your WP admin

    If you see "headers already sent" errors, check the uploaded file for blank space before the opening <?php or after the closing ?>

  3. tophfro
    Member
    Posted 8 years ago #

    Its a little dirty but works, Thanks for the help.

  4. tophfro
    Member
    Posted 8 years ago #

    i noticed that when i hit the back button the post content feild is blank. is there a way to get the text back?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags