4

When do I use the following:

  • home.php
  • frontpage.php
  • Under Settings > Reading Settings
    • Front Page
    • Posts Page

I wish to clarify this as I find myself using "Placeholder Pages", empty pages just for the sake of a menu item and to display blog listings.

If I use a Static Front Page (Set under Settings > Reading Settings > Front Page) how do I access my posts page? Do I need to have a "Placeholder Page" titled blog and use page-blog.php?

1 Answer 1

7

You don't ever directly use (as in, select as a Page template) either front-page.php or home.php. WordPress uses these template files automatically, according to the Template Hierarchy rules.

  • The front-page.php template file is used to display Site Front Page, whether you have set the site front page to display a static Page or the Blog Posts Index.
  • The home.php template file is used to display the Blog Posts Index, whether the blog posts index is set to display on the Site Front Page or an a separate static Page.
  • The front-page.php template file will override home.php on the Site Front Page.
  • The home.php template file will override page.php (or any page-{custom-template}.php selections) on *non-front page static Pages`.

If I use a Static Front Page (Set under Settings > Reading Settings > Front Page) how do I access my posts page? Do I need to have a "Placeholder Page" titled blog and use page-blog.php?

To display the Blog Posts Index on a non-front page static Page:

  • Create a new static Page, with any arbitrary title ("Blog", "News", or anything else you want), and leave the Page Content blank/empty

  • Under Dashboard -> Settings -> Reading, set "Posts Page" to the static Page you just created.

Really; that's it. If you want to customize the display of your static-page-as-blog-posts-index, simply modify the home.php template file. Creating a page-blog.php template file will have no effect.

4
  • You said "You don't ever directly use (as in, select as a Page template)", do you mean if I want a static front page, I should create a page like "Home" with no content, create a custom template for it page-home.php then select that to be the home page?
    – Jiew Meng
    Jan 8, 2012 at 10:39
  • 1
    @jiewmeng see the Creating a Static Front Page Codex entry. The only time that creating your own custom page template for a static front page will work is if your Theme does not include a front-page.php template file. See also: Template Hierarchy. Jan 8, 2012 at 16:08
  • In other words, I should create a page-home.php and an empty page "Home" if I want to have my front page display my latest 3 posts & latest 3 portfolio (custom post type)? Just to confirm my understanding
    – Jiew Meng
    Jan 9, 2012 at 0:49
  • 1
    "I should create a page-home.php and an empty page "Home" if I want to have my front page display my latest 3 posts & latest 3 portfolio (custom post type)?" - actually, I would use front-page.php for that purpose. That way, you don't have to worry about selecting the custom page template; instead, you simply select the appropriate static Page via Dashboard -> Settings -> Reading, and you're done. Jan 9, 2012 at 5:01

Your Answer

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

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