If I create a home.php file, it seems that WP will use that instead of index.php, so index.php is never used?

What are the differences between these two template files (located in the theme folder)? Do they both behave the same way, the only difference being the priority of home.php?

3 Answers 3

  • index.php is universal template, it is what any page (home, archive, single post, etc) will use if no other template is available for it.

  • home.php is a template used for main page (on is_home()) condition.

See Template Hierarchy for detailed scheme of how templates are applied.


home.php is what your site will use for whatever page you set be the "Posts Page" under the reading options in wp-admin. If you set a static page to the front page, you would use front-page.php if you wanted it to be styled specially.


Be aware that using home.php instead of index.php as the front page will disallow an usual posts-from-all-categories page in your blog. In other words, there's no easy way to get to index.php if you use home.php.

  • Can you explain that? Usually, you can get all categories just fine in a home.php. The template will be chosen long after the db query has been made.
    – fuxia
    Commented Feb 5, 2013 at 16:48
  • Yes, but if you try to implement a site structure like this: 1. Home -> home.php / 2. News -> index.php / 3. Post category 1 -> category.php ... then there's no way to show posts from all categories (the role that index.php fulfills) except by creating a static page, a separate page template for it and getting post via a separate query in this template. If we try to link directly to index.php, it obviously redirects us to the page designed by home.php because it's now set as the front page of the blog. Commented Feb 5, 2013 at 18:26
  • home.php is the template for the latest blog posts from all categories.
    – fuxia
    Commented Feb 5, 2013 at 18:39
  • What index.php is for then? Commented Feb 5, 2013 at 22:48
  • It is a fallback file in case any other file is missing. The only file that is not catched by this fallback is the comments.php.
    – fuxia
    Commented Feb 5, 2013 at 23:25

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.