• is there a way to make a conditional thingy so that IF there is no ‘content’ in a post THEN …

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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?

    Thread Starter Pete

    (@perthmetro)

    bump

    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…

    Thread Starter Pete

    (@perthmetro)

    cheers

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Is there a conditional for no content?’ is closed to new replies.