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 WordPress Theme Development The WordPress Loop Adding the Loop to the index.php File

It only shows 'Home' instead of the the title and the content ?

In the index.php file i made the loop but instead of showing actual posts it just shows *Home' ? Made multiple posts and looked through the code but can't seem to find anything really.. The code: <?php get_header(); ?>

<section class="row">
  <div class="small-12 columns text-center">
    <div class="leader">
          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
              <h1><?php the_title(); ?></h1>
              <p><?php the_content(); ?></p>

          <?php endwhile; else : ?>

            <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>

          <?php endif; ?>    
    </div>
  </div>
</section>

<?php get_footer(); ?>

2 Answers

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi, have you switched from static page to latest blog posts in the customizer? Your code seems right, maybe the problem is in the customizer for the static front page.

I didn't notice he did that, thanks for the help! :)

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

I've finished the course today! Glad that I can help you. Happy coding for the rest of the course! ;)

Yeah like Gianmarco said. Your code looks a-ok for a WP loop.