0

In WordPress, I've changed the general settings for my web site to use a static page, pointing the Front page to a custom page called 'Home' which inherits from a template page called tpl-home.php and I set the Blog to a custom page, called 'Blog' which inherits from my default blog.php page.

However, when I browse to Blog, it shows up the blog posts, but within the index.php page? I've googled this, as it's a common bug that developers run into, but none of the recommended solutions work.

How do I know it's the index page if it shows the blog posts? I echo 'Index' in the index.php page :D.

1

As @Michelle rightly pointed out, blog.php is not part of the template hierarchy. Here is what the codex have to say about Custom Blog Posts Index Page Template

To create a custom blog posts index template, include the following in the Theme:

home.php

Use only the home.php template file for the blog posts index. Do not use a Custom Page Template (such as template-blog.php) for two reasons:

  • When the static front page feature is configured properly, WordPress will not use a Custom Page Template to display the blog posts index, even if a Custom Page Template is assigned to the page designated as the "Posts page". WordPress will only use either home.php or index.php.

  • When the Custom Page Template is assigned to a static page other than the one designated as the "Posts page," the blog posts index loop pagination will not work properly.

From you question:

How do I know it's the index page if it shows the blog posts?

If you need to find out which template is used for the current page being displayed, you can pate the following code in your functions.php. (code from this post)

add_action('wp_head', 'show_template');
function show_template() {
    global $template;
    print_r($template);
}
| improve this answer | |
  • thank you for the response. I know that blog.php is not part of the standard flow, that's why it's been created as a template page /* Template Name: Blog */ which I attached as the template for a custom page I create in WordPress called blog. As for the 'question', I was stating that before you guys ask me how do I know it returns the index.php page, I follow the state with the how I know :). – JadedEric Jun 26 '14 at 17:48
  • I don't understand. All pages defaults to index.php if the appropriate template is not found. In this case, home.php doesn't exists, so wordpress will default to index.php. Why don't you just rename your blog.php to home.php – Pieter Goosen Jun 26 '14 at 17:56
  • Pieter, that's correct. I didn't take this into account, as per Michelle's link, the solution became very evident. Thank you – JadedEric Jun 28 '14 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.