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!

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 WordPress Theme Development Adding a Blog to a WordPress Theme Coding the Blog Homepage

Problem with IF / ENDIF

I´m getting this error:

Parse error: syntax error, unexpected 'endif' (T_ENDIF) in /home/vaporiza/public_html/wp-content/themes/VaporizaTheme/home.php on line 24

*** Line 24 is where the IF CONDITIONAL is located.

Please help!

<?php 
/*

Template Name: HomeBlog

*/

 ?>

<?php get_header(); ?>



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


    <article class="post">
        <h1><a href="<?php the_permalink(); ?>"><?php the_title();?> </a></h1>
        <h2><a><?php the_excerpt();?></a></h2>
        <span><?php echo get_avatar( get_the_author_meta('ID'),24);?></span>
        <p><?php the_date();?></p>
        <p><?php the_time();?></p>
        <?php if( the_post_thumbnail() ); ?>
            <p><?php echo "hello";?></p>                            
        <?php endif; ?>
    </article>







    <?php endwhile; endif; ?>


<?php get_footer(); ?>

2 Answers

Bob McCarty
PLUS
Bob McCarty
Courses Plus Student 16,618 Points

Hector,

The embedded 'if' conditional needs a colon (:).

<?php if( the_post_thumbnail()  ) : ?>
        <p><?php echo "hello";?></p>
    <?php endif; ?>

Thank you Bob!! That was the problem with my code.