• 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!)

Viewing 5 replies - 1 through 5 (of 5 total)
  • https://trac.www.ads-software.com please else it doesn’t get seen.

    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.

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

    Thread Starter mike503

    (@mike503)

    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:
    https://michaelshadle.com/2007/07/03/why-does-wordpress-allow-empty-post-titles-and-bodies-on-publish/

    and here is the bug submission:
    https://trac.www.ads-software.com/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.

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress allows empty title posts to publish’ is closed to new replies.