Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress The WordPress Template Hierarchy Homepage Templates in WordPress home.php

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

When do you actually activate the Blog Posts Index Page?

I've watched this video attentively, however I cannot see any other option to actually activate the Blog Posts Index Page. From what I can see in the video, even if you choose to display "Your latest posts" in the Customize menu, you are still using a Site Front Page rather than a Blog Posts Index Page typology. So my question is, what option do you have to select in order for Blog Posts Index Page to be active?

Thank you.

4 Answers

Gleb Vorobjev
Gleb Vorobjev
13,703 Points

This is how I got home.php to be the immediate template of the front page. See if it works for you. I'm not sure if this is the intended functionality or a bug.

From the admin area go to Appearance -> Customize

Open the Static Front Page dropdown menu

Select Front Page displays... "A static page"

Set the Front Page dropdown to "-Select-" which I interpret to be a null or default value

Set the Posts dropdown to something, in this case "Blog"

Good answer. What I'm still confused about is that as long as front-page.php exists and you set the blog to display on the front page, unless you do what you suggested, WP will always load the front-page template, then additionally seems to call home.php.
So what exactly is going here is regards to one page calling the other? Is front-page.php loading the first part of the page then essentially just "requiring" home.php to populate the blog posts?

geoffrey
geoffrey
28,724 Points

Your right, this works, but the behaviour is quite "odd". To see my home.php template as default template, I have to select twice the blog page (front page and post page within the select menus) but It's important to select first the front page and then the post page.

If you don't respect this order, It'll still be the front-page.php template taken as default template oddly...

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Emmanuele Massimi,

I believe that you're actually correct here and there may be a mistake that you have to remove front-page.php in order to activate home.php as the latest blog post listing homepage.

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

Zac,

Thanks for getting back to me. From the template hierarchy I can see that there is a possibility to have either a Site Front Page with "Posts Shown" or a Blog Posts Index Page. In the first instance front-page.php is considered first, and then home.php, however with the second typology home.php is the only file that is considered (other than index.php), whereas front-page.php is ignored altogether (this was also explained cursorily in the introductory video).

So there must be a configuration where you actually have Blog Posts Index Page (rather than Site Front Page) active, but this does not seem to be achievable via the WordPress front-end. Is this correct? Because it's really making me confused.

Thanks again for your time! :)

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

I think that you are correct, although this goes against my understanding of how this should actually work.

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

At least I don't feel stupid by being confused by this WordPress behaviour :)

Varayut Lerdkanlayanawat
Varayut Lerdkanlayanawat
Courses Plus Student 5,439 Points

I have exactly the same question. So, the answer to this question is that the Blog Posts Index Pages path will be never ever used, isn't it?

Nicolas Blanco Mattos
PLUS
Nicolas Blanco Mattos
Courses Plus Student 2,545 Points

This two links give an answer.

http://wordpress.stackexchange.com/questions/110349/template-hierarchy-confused-with-index-php-front-page-php-home-php

https://www.rarst.net/wordpress/front-page-logic/

Basically, front-page.php is a high priority template... so if it exists in your theme files, it will be used on Static Front Page view AND Your Latests Posts view... both options will use front-page.php if it finds the file...

That's the reason why most public released themes don't include a front-page.php

So I think the hierarchy diagram is not accurate, it misses that detail.

missgeekbunny
missgeekbunny
37,033 Points

For home.php, you need to set a static page to your front page and then set another page to be the listing for blog posts. That page will take the home.php format.

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

missybunnie,

Thanks for getting back to me. Unfortunately that is not exactly my problem. If you look at the template hierarchy you will notice that there are two ways to achieve a front page that contains the latest posts: Site Front Page with "Posts Shown" or Blog Posts Index Page, however I do not seem to be able to find a way to enable Blog Posts Index Page which would make WordPress bypass front-page.php altogether (you can also refer to my reply to Zac below).

Thanks for your input anyway! :)