• I have my thumbnails wrapped in a div and I’m trying to hide them if there is no post thumnail. I tried this

    <?php if(has_post_thumbnail()) {
    <div class="left">
    <div class="image_frame">
    path to some image here
    </div>
    <?php the_post_thumbnail(); ?>
    </div>
    } else {
    }
    ?>

    and I get Parse error: syntax error, unexpected ‘<‘. Not sure what I’m doing wrong..

Viewing 2 replies - 1 through 2 (of 2 total)
  • You have an opening <?php tag inside an opening <?php tag.

    Try:

    <?php
    if(has_post_thumbnail()) :?>
    <div class="left">
    <div class="image_frame">path to some image here</div>
    <?php the_post_thumbnail(); ?>
    </div>
    <?php else :?>
    <?php endif;?>
    Thread Starter nemci7v

    (@nemci7v)

    oooh! the brackets confused me. Thanks! It works ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘if post thumbnail exists’ is closed to new replies.