WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] home.php not overriding page.php for homepage

[Resolved] home.php not overriding page.php for homepage

  • semidivine
    Participant

    @semidivine

    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    semidivine
    Participant

    @semidivine

    OK thanks for your reply.

    sampablokuper
    Member

    @sampablokuper

    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

    sampablokuper
    Member

    @sampablokuper

    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.”

    sampablokuper
    Member

    @sampablokuper

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] home.php not overriding page.php for homepage’ is closed to new replies.