We can use Conditional Tags to detect the Blog Page.
It’s not a direct hit but we can make use of is_front_page() and is_home() to detect it.
There is no conditional tag for the blog page.
We have to use both is_home() and is_front_page() to detect this page, but those functions can be misused.
In fact, we can define a static page for the homepage, and another page to display the blog.
This one will return true with is_home() function, even if it’s not the homepage.
Here is what a user can define :
- a default homepage (with the latest posts)
- a static homepage and no blog page
- a static homepage and a blog page
When you use is_home() and is_front_page(), you have to use them in the right order to avoid bugs and to test every user configuration.
This is how we can make use of the Conditional Tags to detect the Blog Page:
if ( is_front_page() && is_home() ) {
// Default homepage
} elseif ( is_front_page() ) {
// static homepage
} elseif ( is_home() ) {
// blog page
} else {
//everything else
}
Credit: WordPress Dev
blog conditional functions is_front_page is_home tags