If the conditional works when using is_page( 'products' )
, but does not work when using is_page( 'blog' )
, then that means that WordPress isn’t finding a static page with the slug blog
. First thing to do: verify your slug name.
A second alternative is that the static page blog
is using a custom page template, and that the custom page template is calling a different header file, resulting in the above code never getting executed. Are you using a custom page template for the static page blog
? If so, you’ll need to look at the custom page template file.
Edit
From your comment below:
i forgot to mention that as home is set as my static page in the admin panel the blog page is set as my blog page.
There’s your answer. I should have picked up on it, but somehow didn’t. Take a look at the Template Hierarchy. You’re using the static page blog
as your Blog Posts Index, Instead of using is_page( 'blog' )
, you need to be using is_home()
, which returns true
when displaying the Blog Posts Index.