WordPress Front Page vs Homepage – WPSaviour

By WP Saviour •  Updated: 04/16/21 •  3 min read

WordPress is a terrific CMS. You are able to do no matter you need with it. However generally, chances are you’ll discover a difficulty with some primary features. For instance, you might be most likely utilizing the is_front_page and is_home WordPress Homepage conditional in your themes and plugins (you’ll be able to study extra about conditional features in our Conditional Tags publish). However you’re doing it mistaken !

Homepage Settings

With these conditional features, you’ll be able to examine if the homepage is being displayed (is_home), or if the homepage is utilizing a static web page (is_front_page). You possibly can outline such behaviour in Settings=> Studying.

In your plugin or theme, chances are you’ll use this features to show or change contents relying on consumer settings. However you might be doing an enormous mistake : you aren’t bearing in mind the static weblog web page. If you outline a static web page on your homepage, you can too outline a weblog web page : it would substitute the default WordPress homepage as a way to listing each publish.

Lengthy story made brief : is_front_page ought to at all times be examined with and earlier than is_home. And right here’s why.

How It Works

1. Regular settings:

The default WordPress homepage lists your newest posts.

Right here, there isn’t any subject.

2. Static homepage:

The homepage is utilizing one in all your static pages.

There is no such thing as a subject together with your static homepage : is_front_page returns true.

3. Static weblog web page

Considered one of your web page is itemizing all of your publish.

Right here, you will have some issues : is_home is returning TRUE, however this isn’t your homepage : it’s a WordPress web page that lists each publish, like a major class archive would do.

Use Conditional Tags

If you create a plugin or a theme, it’s important to think about that customers could use these web page settings. So, each time you utilize is_home, you need to at all times take a look at is_front_page earlier than, and also you at all times ought to use conditional parameters to take action.

When you don’t, you will have issues with some customers. For instance, in case you solely take a look at is_home to show your homepage content material, there might be points with the static homepage that won’t show the correct content material.

Right here is do it proper :

if ( is_front_page() && is_home() ) { } elseif ( is_front_page() ) { } elseif ( is_home() ) { } else { }

That is the one (proper) strategy to show or alter content material together with your homepage and your weblog web page.

gp-5544341 as-6417366

WP Saviour