Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Ivan Yapeter
Ivan Yapeter
12,535 Points

Wordpress: Parse error in Blog Homepage

I have followed and repeat the instruction video a couple of times, but I couldn't figure out where is the error coming from.

Please help me out on this, it giving me Parse error on line 31. That is where the first endif statement located for get_the_post_thumbnail function.

<div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
        <div class="primary">

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

         <article class="post">
              <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
              <h2><?php strip_tags( get_the_excerpt() ); ?></h2>
              <ul class="post-meta no-bullet">
                  <li class="author">
                    <a href="author.html">
                       <span class="wpt-avatar small">
                            <?php echo get_avatar( get_the_author_meta( 'ID' ), 24 ); ?>
                       </span>
                       by <?php the_author_posts_link(); ?>
                    </a>
                  </li>
                  <li class="cat">in <?php the_category( ', ' ); ?></li>
                  <li class="date">on <?php the_time( 'F j, Y' ); ?></li>
              </ul>
              <?php if( get_the_post_thumbnail() ); ?>
                <div class="img-container">
                    <?php the_post_thumbnail('large'); ?>
                </div>
               <?php endif; ?>
             </article>    

     <?php endwhile; else : ?>

            <p><?php _e( 'Sorry, no pages found.' ); ?></p>

    <?php endif; ?>

    </div>
</div>

1 Answer

Ivan Yapeter
Ivan Yapeter
12,535 Points

Found the mistake, I missed out the instruction about if statement semicolon & colon,

mine:

<?php if( get_the_post_thumbnail() )       ;     ?>

instead of:

<?php if( get_the_post_thumbnail() )      :      ?>