Get the Official WPSaviour App Now!

Tips

WordPress Front Page vs Homepage

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 is the URL : web site.com
  • is_home returns TRUE
  • is_front_page returns TRUE

Right here, there isn’t any subject.

2. Static homepage:

The homepage is utilizing one in all your static pages.

  • The URL remains to be web site.com
  • is_home returns FALSE
  • is_front_page returns TRUE

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.

  • The URL is web site.com/pagename
  • is_home : TRUE
  • is_front_page : FALSE

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() ) {

	// Default homepage ( each the entrance web page and the latest posts web page)

} elseif ( is_front_page() ) {

	// Static homepage

} elseif ( is_home() ) {

	// Weblog web page

} else {

	// All the things else

}

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

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogTips

Magento vs WooCommerce – Which one is Better? (Comparison)

Beginner’s GuideBlogTips

12 Best Calculator Plugins for Your WordPress Site

Beginner’s GuideBlogTips

How to Buy a Domain Name That is Taken (9 Pro Tips)

Beginner’s GuideBlogTips

Top 5 free payment gateway plugins for WordPress in India (2020)

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.

Fear Of Missing Out?

Sign up with your email address to receive WordPress tips and updates
SUBSCRIBE NOW
Terms and Conditions apply
close-link
Click Me