• I have a page.

    One of the default attributes of the page, is the ‘Page’ window where u enter your blog text.

    To display the content, I use the the_content() function in the follwoing code:

    if (have_posts()): while (have_posts()): the_post();
       echo '<div class="ui-tabs-panel">';
       the_content(); '<br />';
       echo '</div>';
    endwhile; endif;

    Question: How can I avoid displaying an empty ‘ui-tabs-panel’ if there is no test in the ‘Page’ attribute (empty content) ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Steven

    (@spstieng)

    Ups, spelling mistake.
    It should be ‘if there is no text’

    hi,

    i don’t have anywhere to test this at the moment but you might do this.
    if (have_posts()): while (have_posts()): the_post();
    if($post->content==””)
    {
    //whatever you want to be there if there is no content
    }
    else
    {
    echo(‘<div class=”ui-tabs-panel”>’);
    the_content(); ‘
    ‘);
    echo(‘</div>’);
    }
    endwhile; endif;

    Thread Starter Steven

    (@spstieng)

    Thanks jrm213, but that didn’t work ??

    I tried looking in Function Reference to see if there is anything there I can use. But didn\t find anything.

    Where can I see what properties ‘post’ has?

    Thread Starter Steven

    (@spstieng)

    Anyone got any suggestions for this?

    I was looking for the answer to this too. You were on the right track but missing a word.

    It should be $post->post_content like this:

    <?php if($post->post_content=="") : ?>
    
    <!-- Do stuff with empty posts (or leave blank to skip empty posts) -->
    
    <?php else : ?>
    
    <!-- Do stuff to posts with content -->
    
    <?php endif; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I avoid displaying empty the_content()?’ is closed to new replies.