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?
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 (onis_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 usefront-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.