Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted
  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

share|improve this answer
    
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 Jan 23 '12 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 Jan 23 '12 at 7:28
    
cool. thanks a lot. –  sleeper Jan 23 '12 at 7:34
1  
And just a note, if you're using a static front-page, front-page.php takes precedence to home.php –  m0r7if3r Jan 23 '12 at 10:56
    
Thanks. I opted for using the home.php template page. –  sleeper Jan 24 '12 at 17:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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