WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Blog page constantly reverting to index page (9 posts)

  1. nadine00
    Member
    Posted 3 years ago #

    Hi,

    I have an issue that I seem to only have with wordpress 3+ Basically, if I want a blog page to be something other than the home page, for some reason wordpress reverts to using the index.php rather than the blog.php template i have set up for this purpose.

    Its making me nuts. I have the "BLog" page set up to use the blog template via the dropdown, and the reading options to use the blog page as the Posts page. But it still reverts to index.php

    Now i could just copy the code from blog.php to index.php....except when i put a query in there to display only posts from the blog category, it has a bird and can't find anything.

    I've even tried to rename blog.php to home.php ...no dice. it will still only use index.php

    Suggestions? I'm at my end with this.

    thanks.

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    What is your Front Page set to display: Static Page or Blog Posts?

    If Static Page:
    1) What Page is set to display on the Front Page
    2) What Page is set to display the Blog Posts Index

  3. nadine00
    Member
    Posted 3 years ago #

    Ha! found it. Figures right after I post something.

  4. Samuel B
    moderator
    Posted 3 years ago #

    as far as I know you can't use a custom template for the Blog page
    ref
    http://codex.wordpress.org/Creating_a_Static_Front_Page
    Do not use a custom Page template for this page!

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    @nadine00:

    Ha! found it.

    So, what was it? (In case someone else might be helped by the same solution.)

    @Samuel B:

    as far as I know you can't use a custom template for the Blog page

    Yes, you can; but it has a specific template name.

    The front-page.php template will always be used for the Front Page, whether it is set to display a Static Page or Blog Posts.

    The home.php template will be used to display the Blog Posts Index, whether they are output on the Front Page, or a Static Page.

    The fallback for a Static Page on the Front Page is page.php, and the fallback for the Blog Posts Index is index.php.

  6. lukeratto
    Member
    Posted 2 years ago #

    Chip, please explain the solution? I've been pulling my hair out. So edit index.php directly? (that doesn't sound like a good idea)

  7. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    @lukeratto:

    Chip, please explain the solution? I've been pulling my hair out. So edit index.php directly? (that doesn't sound like a good idea)

    What is your specific problem, for which you need the solution?

  8. lukeratto
    Member
    Posted 2 years ago #

    @Chip Bennett
    I have a static home page template assigned/active and would like to assign a custom template for the "Blog". Basically just having one Category post to the "Blog" with custom sidebar.

    Like you I created a custom blog template file, assigned it and nothing happens, the Blog layout remains the same. From what you wrote above, I need to alter my "home.php" file? So just copy my custom blog template code and paste it in the home.php file and walla?

    Thanks for your time and help

  9. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    Like you I created a custom blog template file, assigned it and nothing happens, the Blog layout remains the same. From what you wrote above, I need to alter my "home.php" file? So just copy my custom blog template code and paste it in the home.php file and walla?

    You already have a home.php template file in your Theme? If so, rename it home-old.php (just as a backup).

    Then, rename your blog.php as home.php. WordPress will automatically use it for your Blog Posts Index, on whatever static Page you have assigned to display your blog posts.

    Note that WordPress will never take into account any custom page template assigned to the static Page that displays the Blog Posts Index. WordPress will only ever use the following template files, in order of preference:

    1. front-page.php (if Front Page is set to display blog posts)
    2. home.php
    3. index.php

    Refer to the updated Template Hierarchy diagram, for a visual explanation regarding why WordPress will never use a custom page template for the static Page assigned to display the Blog Posts Index.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.