Support » Fixing WordPress » Posts page not using index.php OR home.php

  • This is a really strange one for me. I modified a theme for our site and got it all up and running on a staging server. In the settings we have the static front page as Home and the posts page as Blog. I’ve made some modifications to index.php and they show up when you view test.mysite.com/blog/ just fine.

    I just switched our public site over to this new theme. I uploaded it and made the switch and set the front page to Home and the posts page to Blog, but when I go to http://www.mysite.com/blog/ it isn’t using the index.php page I created before. I don’t have a home.php page in this theme so that isn’t the problem either.

    The weird thing is, I don’t even know which template it is using. The posts look like my post in single.php, but it is showing 10 per page like I would expect had it been using index.php.

    I’ve tried copying the index.php and renaming it to home.php with no luck.

    I’ve read through this article and cannot figure out what the problem might be: http://codex.wordpress.org/Template_Hierarchy

    Also searched and read through a bunch of other people who had similar issues and it always turned out to be a simple problem of them not using either index.php or home.php.

    Since the theme and settings are exactly the same on both my test.mysite.com and http://www.mysite.com I’ve got to assume there is something outside the themes directory that is causing this to happen.

    I’m really struggling here. Anybody have any ideas what the problem might be?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Couple of tips to help in debugging.

    First, in each template place an HTML comment that identifies the file. This should go after the call to get_header() if it is used in the file. If you place such a comment in every file you can view the source of the page to see what files were used.

    <?php get_header(); ?><!-- file:index.php -->

    Second, you can add the code below to functions.php to show which template is used. Just comment out the add_action line to turn off the code.

    // identify what template is used
    add_action('wp_footer', 'show_template');
    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>");
       }
    }
    Thread Starter espelund

    (@espelund)

    vtxyzzy, thanks a bunch. That is super helpful. The second solution worked like a charm to show me that my page at http://www.mysite.com/blog/ is being served up by archive.php.

    But I have absolutely no clue why it would be doing that.

    The theme is identical between my test site and live site. I believe all the settings available via the admin UI are identical (though I could be missing something there).

    I’m wondering if at some point some of the main WP files outside of the theme were modified to, for some reason, use archive.php for the main blog posts page?

    Thread Starter espelund

    (@espelund)

    So I just changed the name of archive.php to archive.php.bak and that fixed my issue. /blog is now showing using index.php as I wanted. That template is also served up for archive pages, which isn’t ideal, but works fine for the time being. Still want to figure out why the heck archive.php is being used for the main posts page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts page not using index.php OR home.php’ is closed to new replies.