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 trialJake Ford
9,230 PointsIs there not an easier way to add a read more button than I did?
I spent a little too much time on this, but finally got it working!
<h2><?php echo strip_tags( get_the_excerpt() ); ?>
<?php if( str_word_count( get_the_excerpt() ) > 16 ) : ?>
<a style="font-size: .6em;" href="<?php the_permalink(); ?>">READ MORE</a>
<?php endif; ?>
</h2>
Although, I thought the logic could have been like this:
<?php if( get_the_excerpt() ) : ?>
Wouldn't this if statement check to see if there is an excerpt for the post and then display read more? I thought this way would work..