2

OK. I'm getting conflicting instructions from my training resources (again).

This time the issue for me is "how to set a default homepage".

One tutorial (Coyers "WordPress 3: Creating and Editing Custom Themes") uses home.php, while another ("Professional WordPress") recommends setting "Front page displays..." via WordPress (Settings > Reading). ...aargh!

In checking the forums and blogs, I see the same issue: conflicting advice. With one user advising to NEVER use the home.php template page in a theme as "It can cause problems on some servers". Is this true? And another user swearing by it.

...What is a noob to do?

So, given the confusion (and given that I'm a noob looking to do things the right way)...

  1. What is the difference between the two approaches?
  2. Which approach to a standard homepage should one use when creating a theme?

thanks,

sleeper

1 Answer 1

3
  1. Simply put, the WordPress template hierarchy reserves home.php for the homepage, but if you set a Front Page post, it will display that instead. If WordPress core developers reserved it for the homepage, I do not believe it would cause issues with any servers, because they would be putting everyone at risk. Hope that explains it for you. :)

  2. It is completely personal preference.

From the WP Codex:

  1. WordPress first determines whether it has a static front page. If a static front page has been set, then WordPress loads that page according to the page template hierarchy.
  2. If a static front page has not been set, then WordPress looks for a template file called home.php and uses it to generate the requested page.
  3. If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page.

See the relevant WordPress Codex page for more information: http://codex.wordpress.org/Template_Hierarchy

5
  • thanks for responding. Need a little clarity "the WordPress template hierarchy reserves home.php for the homepage" so.. I CAN use home.php as the homepage of the site "but if you set a Front Page post, it will display that instead." which I would NOT do if I choose to use home.php. Correct? thanks sleeper
    – sleeper
    Commented Jan 23, 2012 at 7:26
  • @sleeper Basically it goes: 1) Static 'Front Page', 2) home.php, 3) index.php -- in that order. If 1 isn't there, it uses 2. If 2 isn't there, it uses 3.
    – Jared
    Commented Jan 23, 2012 at 7:28
  • 1
    And just a note, if you're using a static front-page, front-page.php takes precedence to home.php
    – mor7ifer
    Commented Jan 23, 2012 at 10:56
  • @sleeper Glad you figured it out! If my answer lead you to the right place can you mark it as accepted please?
    – Jared
    Commented Jan 24, 2012 at 18:02
  • @Jared >> Sorry about the delay Jared (had a "life" interruption). Yes, it did lead me in the right direction. Marked as accepted.
    – sleeper
    Commented Jan 25, 2012 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.