4
votes

So I am trying to get my blog page to use home.php as per template hierarchy, but it seems to not be using it. I am also using a front page that is properly using front-page.php.

If I got to settings->reading-> and select my blog page as the post page it seems to skipping over home.php and going to index.php.

I also went to appearance->customize and selected the blog page there and when I select the blog page there it temporarily shows up as home.php but as soon as I save and close and go back to the blog page it reverts to index.php.

I have found a temporary solution that is the wrong solution. I duplicated home.php and re-named it archive.php and it is now using archive.php instead of index. Which is weird it just seems to not be following the hierarchy at all.

I did find someone else with the same problem and he simply reverted his home.php to index.php :

WordPress posts page PREVIEW using index.php instead of home.php

I used the following code(in functions.php) to display which template the page was using:

function show_template() {
   global $template;
   if ( current_user_can('administrator') ) {
      print_r("<div class='template-name' style='padding: 5px; border: 3px solid red; background-color: #FFFFFF; position: fixed; bottom: 0; left: 0;'>$template</div>");
   }
}   
4

4 Answers

1
votes

Instead of home.php you should use front-page.php. Unfortunately, the Template Hierarchy description is outdated and doesn't mention that home.php doesn't work (although it does state that if front-page.php is present it will be used before index.php).

1
votes

Another work around is to create a page template (page-blog.php). In that file make sure you add this at the top so that you can select this file on the template dropdown:

<?php /* Template Name: Blog Page */ ?>

Set your blog page to that template. Then in the reading section, if you haven't already or it gets reset, set the blog page to the blog page you created.

0
votes

You can create file called page-home.php in the theme root

Then inside that include

<?php /* Template Name: Home Page */ ?>

Then create a page called Home and select the template Home Page

Then goto settings -> reading -> a static page -> front page = Home

0
votes

I know this is a year old, but I just ran into the same problem and managed to fix it by deleting every single file within the theme and then re-uploading all the files.

I have no idea why this worked, but it did.