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 trial

WordPress

Gareth Edwards
Gareth Edwards
7,243 Points

The WordPress Loop - content not appearing

Hi,

I've been working through the Wordpress development track.

Currently, I'm on to the Wordpress loop video.

At about 3.50 on the video, Zac has completed the loop in order to display content on the home page of allisongrayce.com. In the text editor, we are working on the file front-page.php.

My code is the following.

<?php get_header(); ?>

<p>This is the front-page.php file.</p>

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

    <h3><?php the_title(); ?></h3>

    <p><?php the_content(); ?></p>
    <hr>

<?php endwhile; else: ?>

<p>There are no posts to display here</p>

<?php endif; ?>

<?php get_footer(); ?>

When I refresh in the browser, the text I have displayed looks like so:

This is the header.

This is the front-page.php file.

There are no posts to display here.

This is the footer.

My h3 tag containing the text 'Home' does not display, and neither does my hr tag.

I can see that this question has been posted on the forum before but it's been left unanswered.

If anyone could point me in the right direction it would be much appreciated.

Many Thanks.

1 Answer

Andrew McCormick
Andrew McCormick
17,730 Points

try removing your <h3> tags and using <?php the_title( '<h3>', '</h3>' ); ?> instead.

http://codex.wordpress.org/Function_Reference/the_title