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


the_content not displaying in custom wordpress theme

On my page.php page I am wanting to display the_content but it is not showing up.

My code looks like you'd expect...

<?php the_content(); ?>

Does it only work in the loop?

How can I fix this problem?

1 Answer

Wally Soukoroff
Wally Soukoroff
6,649 Points

Hey Joel, you need to put "the content" function call inside the WordPress loop in order for it to output your content to the page like the following.

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

Also dont forget to get the header and the footer for your page template too.

Hope that helps, Cheers!!!