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 trialGarrett Lovell
5,527 PointsConvert Blog Listing and Single Post Templates
The problem that I have happens around the 4:40 mark. I get this
Parse error: syntax error, unexpected 'else' (T_ELSE) in /Applications/MAMP/htdocs/allisongrayce.com/wp-content/themes/wpportfolio/content-post.php on line 19
Yet my code is exactly the same as the code shown in the video.
I've checked my code over and over for my content-type.php file. What am I missing?
<div class="clearfix">
<header class="title">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</header>
<ul class="info">
<li>Posted in: <?php the_category(', '); ?></li>
<li>Written by: <a href="<?php bloginfo('siteurl') ;?>/about/"><?php the_author(); ?></a></li>
<li>On: <?php the_time('F j, Y'); ?></li>
</ul>
<div class="excerpt">
<?php if(is_single()); ?>
<?php the_content(); ?>
<?php comments_template(); ?>
<?php else; ?>
<?php the_excerpt(); ?>
<p><a class="post-link" href="<?php the_permalink(); ?>">Continue Reading →</a></p>
<?php endif; ?>
</div>
</div>
1 Answer
eirikvaa
18,015 PointsTry this:
<div class="excerpt">
<?php if(is_single()) : ?>
<?php the_content(); ?>
<?php comments_template(); ?>
<?php else : ?>
<?php the_excerpt(); ?>
<p><a class="post-link" href="<?php the_permalink(); ?>">Continue Reading →</a></p>
<?php endif; ?>
I switched out the semicolons after the first if and after the else statement, and indented correctly.
Garrett Lovell
5,527 PointsGarrett Lovell
5,527 PointsThat did it. Being a beginner, I'm still trying to wrap my head around all this stuff. Thanks, man!
eirikvaa
18,015 Pointseirikvaa
18,015 PointsYeah, but that's the beauty of it - there's so much to learn. Glad to help!