Difference between home.php and front-page.php

With WordPress 3.0 release, a new page template was introduced as front-page.php. Now to show the front page, a developer has now 3 options namely – index.php, home.php and front-page.php Now the problem is which template is to be used when and how does WordPress decides which template to load when and how to avoid conflicts between them. For example, if a theme ships with all 3 – index.php, home.php and front-page.php, which file will be loaded by WordPress?

Well in this post, I will try to clear some of the confusion surrounding these templates. Now since front page is controlled from options panel under Dashboard>>Settings>>Reading so I will take up both options of selecting front page and then discuss how WordPress selects your front-page.

When Front Page is selected to show Latest Posts

Now if option of showing latest posts is selected, WordPress will first search for front-page.php template. If its found, then it will be loaded irrespective of the fact whether index.php or home.php are present or not. If front-page.php is not found then it will load home.php and if that’s also not present, finally it will load index.php to show the latest posts.

When Front Page is selected as a Static Page

Now if static page is selected for the front page, WordPress will again search for front-page.php template first and load it its found to show the static page. Now if that static page is styled using custom template, then instead of front-page.php, that template file will be used to show the front page. And if front-page.php is not found then it will load page.php template file or the respective custom template for that static page.