index.php template is used instead of blog page

I am trying to set WordPress so that home page is static, and the blog page is a separate page. So, I created two page templates in my theme., lets call them home_template and blog_template.

Then, I created two WordPress pages (from Pages -> Add New). The first page is called Home, and is using home_template; and the second is called Blog and is using blog_template.

Read More

Then I went to the Settings -> Reading setting, and chose Front Page Displays A Static Page. And in the two drop downs that follow, I chose Home for Front Page, and selected Blog for Posts Page.

Then I went to Appearance -> Menu, and added the Blog page as a menu item.

Now, when I go to view my site, the home page is nice and dandy. However, when I click on the menu item for the blog page, I see that the blog page is using index.php to display its content, it is not using the page blog_template to display the content.

How can I make sure that the blog_template page is used? Please help and thanks.

Related posts

2 comments

  1. When you make a page the page for posts, it’s no longer a “page” in the conventional sense. Refer to the Template Hierarchy for home page display- the quickest fix is to rename your blog template home.php, and WordPress will load that before index.php.

  2. Do you have any archive.php file in your theme files? This should be the first file that is rendered when viewing the posts page. If it’s not in there, then it defaults to using the index.php file. I would suggest renaming your blog_template file to be ‘archive.php’ if you don’t have an archive page, or better yet, change it to ‘archive-post.php’ and see if it gets rendered correctly.

    If in your blog_template file you are coding it to pull in the blog posts and have it formatted in the way you want, then I would say that in the Settings, do not set anything for posts page. That way, when you go to your “blog” page, the system will use the blog_template to render the view.

    Going this route means that the template file will need to run the query for all posts, because when the page loads, the global object query will only have that page.

Comments are closed.