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 From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Revisit Our Default Index.php Template

Dawn Foster
Dawn Foster
1,899 Points

When is index.php used as a default template page?

Can you explain when the index.php page get's used as a default template when you have the following pages created.

For Blog pages, it appears it uses the home.php page, and for individidual post pages it uses single.php, and for archived posts it uses archive.php.

For the Front page, it uses front-page.php.

For anyother page it defaults to page.php

So if you have home.php, single.php, archive.php, front-page.php, and page.php.. when is index.php ever used by WP as the default template to use?

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

index.php gets used whenever the other default template options are not included in a theme. If you do include all the files it doesn't get used. You might want to check out the courses recommended on Template Hierarchy for more on this.

Dawn Foster
Dawn Foster
1,899 Points

Thanks, Zac. Yes, I will definetly take that course.

Hi Dawn,

The WordPress Codex has a visual overview of the hierarchy including fallbacks, etc.

You can also find this here with click-throughs to the relevant codex page.

Zac goes through it in The WordPress Template Hierarchy course too here.

Hope that helps.

-Rich

Dawn Foster
Dawn Foster
1,899 Points

Thanks Rich. I love the link you gave me to the visual Template Hierarchy. That will be a very valuable resourse as I learn WP.

No problem. Glad I could help :)