I’m new to WordPress. I am looking for a way to check if current page is the blog page in the code of the header file.
I’ve checked but I can’t find a way. Help me, Pls.
I’m new to WordPress. I am looking for a way to check if current page is the blog page in the code of the header file.
I’ve checked but I can’t find a way. Help me, Pls.
If by ‘blog page‘ you meant a static page set as posts page in the Reading Settings, then you could check it by doing this:
if ( is_front_page() && is_home() ) {
// Default homepage
} elseif ( is_front_page() ) {
// static homepage
} elseif ( is_home() ) {
// blog page
} else {
//everyting else
}
When you use
is_home()
andis_front_page()
, you have to use them in
the right order to avoid bugs and to test every user configuration.
(Source: Conditional Tags – The Blog Page)
Or simply:
if ( !is_front_page() && is_home() ) {
// blog page
}
Or more simply (I suppose):
if ( is_home() ) {
// blog page
}