Wordpress - if the post has content

The content is a property of the post object, not of the query object.

Use $post or get_post() instead:

if( '' !== get_post()->post_content ) {
// do something
}

What about

if ( !empty( get_the_content() ) ){ 
//code 
}

This also works, and tests for things like empty paragraph tags or   in the content which might cause a normal check to fail. See http://blog.room34.com/archives/5360 for the original idea - just recording it here so I can find it again. :O)

Put this in your functions.php:

function empty_content($str) {
    return trim(str_replace(' ','',strip_tags($str))) == '';
}

And put this where you want to run the check:

if (function_exists('empty_content') && empty_content($post->post_content)) { ... }

That will return true if the content is empty, false if not.

Tags:

Content