WordPress.org

Ready to get started?Download WordPress

Forums

Posts page not using index.php (6 posts)

  1. mbeebee
    Member
    Posted 5 years ago #

    Hi,
    I'm using a static home page, and a secondary page for posts using default template (index.php) ("Default Template" selected on the Edit Page page). Everything worked fine this morning.

    This afternoon the posts page no longer uses index.php to display posts. I don't know what template it's using, but it's not index.php (I've modified it as a test with no result). No matter what template I try (archives, links, etc.), nothing changes.

    Any thoughts on what happened? How do I figure out what template it's using?

    Thanks

  2. stvwlf
    Member
    Posted 5 years ago #

    Hi - Add a comment to the top of your template pages

    <!--- index.php -->
    
    <!-- category.php -->

    etc.

    Then you can View Source and see which template is being used.

    While you're at it its a good idea to add another comment at the bottom

    <!--- end of index.php -->

  3. mbeebee
    Member
    Posted 5 years ago #

    Great idea -- thanks.

    It looks like it's using my home page template (home.php) for the posts, even though I have the "Travelogue" page selected for displaying posts (Settings/Reading). (The Travelogue page, in turn, has "Default Template" selected under Template. The default template should be index.php, no?)

    But it looks like the main problem is WP is using the wrong template file for displaying posts. Now what? I'm not sure how else to point WP to a specific file other than the Settings/Reading section.

    Thanks so much.

  4. stvwlf
    Member
    Posted 5 years ago #

    Hi

    This page contains all the rules on how WP picks the template it displays a page with, plus a big diagram of the hierarchy. See if any of this is useful

    http://codex.wordpress.org/Template_Hierarchy

  5. mbeebee
    Member
    Posted 5 years ago #

    Thanks stvwlf -- that did the trick.

    I was using home.php as the home page, so when WP tried to display the posts page, it used home.php, which takes precedence over index.php. I changed home.php to homepage.php, updated the settings, and everything works fine.

    Thanks again!

  6. Corey McKrill
    Member
    Posted 4 years ago #

    I had this same problem, and mbeebee's solution worked for me too. It would be great if this page had a bit more clarification about how templates are used for the Front Page and the Posts Page.

    For example:
    Title the second one as "Blog" (or you could call it "News", "Articles", etc.). This page will be a place-holder for showing the Posts on your site.

    1. Custom Page templates will not work for this page! This page will automatically use the index.php template. (Note: if your static home page uses a custom template file named home.php, this page will use it as well, due to template hierarchy rules, and will not display your posts.)
    2. DO NOT add content to the Blog Page. Leave it blank. Any content here will be ignored -- only the Title is used.
    3. Publish the Page.

Topic Closed

This topic has been closed to new replies.

About this Topic