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 Building Page Templates in WordPress The page.php File

home.php fallback?

As I understand it, according to http://wphierarchy.com, if we set the front page to display "your latest posts" then WP will first check for front-page.php, then fallback to home.php.
In the case of this example until now, we only have index.php and have not created front-page.php nor home.php, however the frontpage is falling back on index.php (index.php is being used to populate the front page with the latest posts).
My confusion arrises from the fact that http://wphierarchy.com does not indicate that home.php would fallback on index.php....is that a typo?

Gabriel Ward
Gabriel Ward
20,222 Points

Hi Nijad,

My interpretation is that WP checks the front.page first. If it doesn't, it first goes to the home.php. If it doesn't have home.php, then the alternative route from front.php is taken where it goes towards page.php and eventually onto index.php.

Hope that helps clarifies things for you.

Thanks Gabriel.
I guess the takeaway is that index.php is the ultimate fallback...

1 Answer

Nijad,

In WordPress, the end-all be-all to the hierarchy is the index.php file. You can actually have an entire WordPress website with just the index.php page (although all pages will be in the same format). Just remember that index.php is the last catch in the hierarchy. Even though home.php doesn't show the fallback to index.php in the website you are referring it, it is the last fallback under that section. And if there are no template files in that section, it will fallback to the final catch in the sequence, the index.php page. Hope this helps.

Cheers!

Thank you!