#StandWithUkraine

WordPress front page logic cheatsheet

WordPress front page logic is a mess. No — a Mess. :)

It is an old artifact of development, from the time when WP started to break away from purely blogging paradigm. The static front page functionality was added, but in quite an awkward way.

I have stumbled over this innumerable times and finally decided to note down how it works once and for all.

Front page cheatsheet

Default Static front page
Front page displaysYour latest postsFront page: FrontPosts page: Posts
URLexample.com (site URL)example.com/posts (page URL)
Template hierarchyfront-page.phphome.php
home.php- $custom.php - page-$slug.php - page-$id.php - page.php - singular.php
index.php
Body classes- home - blog - home - page - page-id-$id blog
Loop and contentposts indexpageposts index
home_url()https://example.com
get_post_type_archive_link('post')https://example.comhttps://example.com/posts
is_front_page()truefalse
is_home()truefalsetrue
is_page()falsetruefalse
get_option( 'show_on_front' )'posts''page'
get_option( 'page_on_front' )0Front page ID
get_option( 'page_for_posts' )0 Posts page ID

What is home?

The one especially confusing mismatch to note is that home is all over the place.

home body class and home_url() function refer to front page. They mean location in site (Site URL).

home.php template and is_home conditional refer to posts index. They mean type of page in site (blog posts).

Front page template

front-page.php template is great for very custom front pages. Since it has high priority in both cases of template hierarchy — it is hard to override and publicly released themes rarely include it.

Be aware of it for custom builds, it makes things easier for them.

Summary

Default front page behaves as combination of front page and blog posts archive.

Static front page resides at front page location and behaves as a page.

Posts page resides at assigned page’s location, but behaves as a blog posts index (it being a page is mostly ignored).

TL;DR

In a nutshell you use:

  • static front page to customize, moving archive from there;
  • posts page to change location of posts archive.

Materials used

Related Posts

2 Comments

  • janw.oostendorp #

    Here is a very nice overview of the templates logic: https://wphierarchy.com/
  • Andrey “Rarst” Savchenko #

    Not a fan of that one myself, difficult to follow for my taste. I tend to use one from Chip, but it got some recent bits missing (like singular.php).