WordPress.org

Forums

WordPress allows empty title posts to publish (6 posts)

  1. mike503
    Member
    Posted 8 years ago #

    I can understand WP allowing empty titles on a draft, since it might not be determined yet. However, at publish time, it should not allow an empty title for a post.

    I can't determine any point to where a plugin (action hook, etc.) can be made to check for this condition. I think a slight modification to the core code is prudent.

    wp-includes/post.php:

    if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) )
                    return 0;

    Should be something like:

    if($post_status == 'publish') {
     if ( ('' == $post_content) || ('' == $post_title) || ('' == $post_excerpt) )
                    return 0;
     } else {
     if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) )
                    return 0;
    }

    Optionally it can ignore needing to check to make sure there is content in the post body. But an empty title means that the links to click on the title are blank too... it doesn't make sense (nor can it really make a useful post slug out of that!)

  2. drmike
    Member
    Posted 8 years ago #

    http://trac.wordpress.org please else it doesn't get seen.

  3. Doodlebee
    Member
    Posted 8 years ago #

    wow - that's considered a bug?

    I happen to like the fact that I don't have to give my posts titles. Sometimes I just don't want to.

  4. whooami
    Member
    Posted 8 years ago #

    Ive never done it -- but I wouldnt call it a bug either.

  5. mike503
    Member
    Posted 8 years ago #

    it's definately a bug. it even has code in there to check for empty post titles and such. however, it allows them for drafts and due to that, ignores the difference between publish and draft. this quick code snippet (i haven't tested it) should fix that. in the meantime i've made a functional plugin to work around it:
    http://michaelshadle.com/2007/07/03/why-does-wordpress-allow-empty-post-titles-and-bodies-on-publish/

    and here is the bug submission:
    http://trac.wordpress.org/ticket/4583

    (i forgot that there is a trac here... they should have a link either on the nav bar called "bugs" or when you click on "support" at least!)

    doodlebee: how do your post slugs get generated then? or are you all just ID based? also, there could always be a checkbox or WP setting to allow empty titles or not. that would be another way around it.

  6. Doodlebee
    Member
    Posted 8 years ago #

    Sorry Mike - been busy :)

    You know, never paid attention. I have some sites/themes I've messed with to go by ID for my permalinks - I don't use slugs that often. My normal permalink structure (or some of them, anyway) is date-based, not name based. I fi want a slug, I'll put on in myself, but usually that's only so I can do some sort of design thing (get the slug and change the background based on the slug name) or something like that.

Topic Closed

This topic has been closed to new replies.

About this Topic