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

Alex Bahler
Alex Bahler
8,034 Points

How to Build A Wordpress Theme: "The Loop" not working

The video I am stuck on is "WordPress Theme Functions" in the "How to Build a WP Theme" project.

I have created The WordPress Loop, and pasted it into the front-page.php file between the header and footer includes. I have three blog posts under the "Posts" section of the admin menu, as well as a page called "Blog" under "Pages."

The video makes it look like the "Blog" page is supposed to go to the front-page.php template and display all posts, but when I click "view page" in wp-admin, it goes to the page.php file instead. I put the Loop in that file, figuring I'd make that work for me instead, but it's not grabbing the three blog posts I have published. It only displays the included header, the "this is page.php" message, the "Blog" page title and <hr> I added, and the included footer.

Can someone help me debug this?

EDIT: it is displaying the posts when I click "view page" on the "Contact" page under "Pages." So I can confirm The Loop is working somewhere.

Alex Bahler
Alex Bahler
8,034 Points

I just figured it out (thank you, Codex):

Under Settings > Reading, I had accidentally set "posts page" to "Contact," as it was right below "Blog" in the selection menu.

Thanks anyway, Treehouse!

-Alex

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Yay! Way to check the Codex :)

1 Answer

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Glad this was resolved! I'm just answering this post so it doesn't appear in the "unanswered" section of the forum anymore.