Yogesh Chauhan's Blog

What are Conditional Tags in WordPress?

in WordPress on January 31, 2021

The Conditional Tags are used to change what content is displayed and how that content is displayed. We can also check if that page matches some conditions.

For example, you might want to display a snippet of text above the series of posts, but only on the main page of your blog. With the is_home() Conditional Tag, that task is made easy.

All of the Conditional Tags test to see whether a certain condition is met, and then returns either TRUE or FALSE.

Some of the Conditional Tags can accept parameters as well.

Some of the Conditional Tags examples.


We can check when if main blog page is being displayed using this tag.

This is the page which shows the time based blog content of your site, so if you’ve set a static Page for the Front Page, then this will only be true on the Page which you set as the “Posts page” in Administration > Settings > Reading.


Using this tag we can check when the front of the site is displayed, whether it is posts or a Page.

It returns TRUE

✔ when the main blog page is being displayed and the ‘Settings > Reading ->Front page displays’ is set to “Your latest posts”,


✔ when ‘Settings > Reading ->Front page displays’ is set to “A static page” and the “Front Page” value is the current Page being displayed

Credit: WordPress Dev

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
List of social media icon logo color codes in HEXMiscellaneousEverything you need to know about ANY, SOME and ALL Operators in PostgresPostgresHow to use PHPMailer to send an Email via Gmail SMTP Server?PHPHow to draw an SVG path on scroll using JavaScript?JavaScriptThe substr() method in JavaScript and how it’s different from substring()JavaScript5 Key Principles Of Good Website UsabilityUI/UX