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 Driving me nuts

Ok so Wordpress wins again

I have http://www.plusonetesting.co.uk/cooper/news/

which is set to be the page which displays my posts (under the reading section in Settings - as I am using Home as a static home page).

I have this basic loop in there just to show something on the page (not interested in formatting at this stage).

I have a post in the posts section which I am expecting to show - but alas nothing (well sort of) - can anyone help please.

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?> <h2><?php the_title();?></h2> <div class="entry"> <?php the_content(); ?>

7 Answers

Jon Hockley
Jon Hockley
3,781 Points

There is a post showing?

Ah yes Jon but it is not the post from the posts section it appears to be just showing the page name as a h2 title

Jon Hockley
Jon Hockley
3,781 Points

Which file are you editing?

Jon Hockley
Jon Hockley
3,781 Points

Just a tip: I would recommend using body_class() inside your body element in header.php

This will help you work out which file Wordpress is using to display the page (And save me asking you ;) )

jeff creamer
jeff creamer
23,733 Points

Graham, in "View Source" mode, it appears you've used the WordPress.org/codex instruction file but removed all of the actual php loop commands, so there is no loop. Where is the loop code you listed above, and does it also include the 'else' and 'endwhile' parts of it? Hope that helps a bit.

Jon Hockley
Jon Hockley
3,781 Points

Jeff,

PHP code isn't rendered in the browser, so we won't see it in the source code when viewed using the inspector.

Ah it because I was not using home.php for the articles that I wanted to show therefore it was just showing the loop of the actual page contents and not the posts.. DOH!!