WordPress WordPress Theme Development Adding a Blog to a WordPress Theme Coding the Blog Homepage

Aaron Eldredge
Aaron Eldredge
3,072 Points

Parse error Unexpected endif line 35

<?php get_header(); ?>

<section class="two-column row no-max pad">
      <div class="small-12 columns">
        <div class="row">
          <!-- Primary Column -->
          <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 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 ); ?>
                      by <?php the_author_posts_link(); ?>
                  <li class="cat">in <?php the_category(); ?></li>
                  <li class="date">in <?php the_date(); ?></li>

                <?php if( the_post_thumbnail() ): ?>
                <div class="img-container">
                  <?php the_post_thumbnail('large'); ?>

                <?php endif; ?>

    <?php endwhile; else : ?>

      <p><?php _e( 'Bummer, nothing to see here.', 'treehouse-portfolio' ); ?></p>

    <?php endif; ?>


<!-- Secondary Column -->
    <div class="small-12 medium-4 medium-pull-8 columns">
    <div class="secondary">
        <h2 class="module-heading">Sidebar</h2>

<?php get_footer(); ?>

1 Answer

Hi is this the home.php template? If so I can drop you in the final version from when I completed the course for you to compare your code with?


Actually, it may well be the missing space between the final parenthesis in the post_thumbnail if statement.

I have the code as the following:

                <?php if( get_the_post_thumbnail() ) : ?>
                <div class="img-container">
                  <?php the_post_thumbnail('large'); ?>
                <?php endif; ?>  

Look at the top line of the snippet, in comparison to your code above there is a space between the last parenthesis and the colon.

I am unsure how this will affect things mind but its the only thing I can spot.