I was watching a WordPress course, the explainer has page.php
and index.php
theme template files. Which means the page.php
must load the home page, but the home page is loaded with index.php
!
I used his same files, but I have page.php
loading the home page!
How does his setup override it but mine doesn’t?
1 Answer
WordPress Template Hierarchy:
You should read about WordPress template hierarchy.
This question also has some related answers.
Typical Case:
In your case, the most likely scenario is:
The explainer had set the latest posts as the home page (this is the default option) and you have set a static front page as home page. Since his is blog archive, it’s being loaded by
index.php
and yours is a page, so that’s being loaded bypage.php
.
This is just a typical scenario, but there may be other settings that are affecting which template file is being loaded.
Changing the default setting:
If the above is your scenario, then changing the following setting from WordPress wp-admin -> Settings -> Reading -> Your latest posts
(then Save Changes
) will make it the same for you and the explainer. Check the screenshot below: