WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] home.php not overriding page.php for homepage (6 posts)

  1. semidivine
    Member
    Posted 5 years ago #

    My generic page template and my home page template need to be quite different so I just attempted to create a home.php file and according to the template hierarchy it is supposed to override page.php for the home page, but it is not. Does anybody know why?

  2. moshu
    Member
    Posted 5 years ago #

    If you are using the "front page" option from Options > Reading then you do NOT need any home.php template. That's for older versions, and in the newer ones is counterproductive.
    Just use a regular Page template to achieve different layout for frontpage.

  3. semidivine
    Member
    Posted 5 years ago #

    OK thanks for your reply.

  4. sampablokuper
    Member
    Posted 5 years ago #

    I've just been experiencing the same problem as semidivine reported above.

    If you are using the "front page" option from Options > Reading then you do NOT need any home.php template. That's for older versions, and in the newer ones is counterproductive.
    Just use a regular Page template to achieve different layout for frontpage.

    I don't understand why you say it's counterproductive.

    The problems I see with not being able to use home.php to acheive a specific layout for the front page are:

    • This contradicts the stated template hierarchy. As we all know, when the docs and the code don't match, developers suffer. Well, I'd been suffering at least half an hour before I stumbled on this forum thread, because I read the docs and trusted them.
    • Using a file other than home.php for the "home" page is inelegant: it means that for no good reason, you have to call your home page something other than "home", or call your home page's template something other than home.php, or both… just because home.php's functionality is broken.

    IMHO, this is a bug.

    That said, I'm still fairly new to WordPress development, so perhaps I've missed the point. If I have, please explain to me what I've failed to understand so far. If not, I'd be grateful for suggestions about where to patch the core files (to fix the home.php functionality) so that I can do this and file a bug report.

    Many thanks,

    Sam

  5. sampablokuper
    Member
    Posted 5 years ago #

    NB. This is the stated template hierarchy I was referring to, specifically the part that says, "If a visitor goes to your home page at http://domain.com/wp/, WordPress looks for a template file called home.php and uses it to generate the requested page."

  6. sampablokuper
    Member
    Posted 5 years ago #

    I'm guessing this thread isn't getting any attention because of the fact it's marked as "resolved", so I've started a new thread here.

Topic Closed

This topic has been closed to new replies.

About this Topic