Not totally sure, but the global variable $content holds the content of a post.
So I wonder if you could use if(empty($content)) in some way to check if a post has no content?
Thread Starter
Pete
(@perthmetro)
I’d love to know how to do this as it would be great to be able to fall back on a custom field if there is no content?
global variable $content holds the content of a post.
Doesn’t work as a global for me (i tested to confirm – inside the loop).
print_r( $content );
and then..
global $content; // To see if the var is actually available just outside the scope of my call..
print_r( $content );
Nothing on the page.
You could use something like …
if( empty( $post->post_content) ) {
// Do whatever you want here
}
else {
the_content(); // Or whatever
}
Which does seem to work…