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 trialHector F.
27,464 PointsProblem 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
Courses Plus Student 16,618 PointsHector,
The embedded 'if' conditional needs a colon (:).
<?php if( the_post_thumbnail() ) : ?>
<p><?php echo "hello";?></p>
<?php endif; ?>
Hector F.
27,464 PointsThank you Bob!! That was the problem with my code.