WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to Wordpress. I need to check in header file if current page is the Blog Page?

I checked but I can't find the way. Help me, Pls.

share|improve this question

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() and is_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
share|improve this answer
One use case to use if ( !is_front_page() && is_home() ), at least in my opinion, is if you are distributing a theme that has different layout style for the default homepage and the blog page. – Giraldi Aug 3 '14 at 7:03
This should be the answer :) – Tim Malone Apr 17 at 22:05

You can use the following in your themes functions.php file:

function is_blog () {
    return ( is_archive() || is_author() || is_category() || is_home() || is_single() || is_tag()) && 'post' == get_post_type();

And then put this in the file you are checking:

<?php if (is_blog()) { echo 'You are on a blog page'; } ?>

You can use Hooks in your functions.php file to hook the above, to make that appear on every page.

share|improve this answer
This is a great answer if you want to determine if you're on a blog page, but not neccessarily the blog page (as in the blog home page). See @Giraldi's answer for that. – Tim Malone Apr 17 at 22:04

You can use

<?php if ( is_single() ) { ?>

Do stuff here

<?php } ?>
share|improve this answer
Doesn't work if you've changed the blog page – cdmckay Oct 9 '14 at 15:09

I use this way

// Get body classes as array
$body_classes = get_body_class();
// Check if "blog" class exists in the array
if(in_array("blog", $body_classes)) {
   // Do stuff
share|improve this answer

If by 'blog page' you meant a static page set as posts page in the Reading:

global $wp_query;

if ( isset( $wp_query ) && (bool) $wp_query->is_posts_page ) {
    //static blog page

PS. This solution also works on template_redirect action

share|improve this answer
Hi repinsa, welcome to WPSE :) Thanks for adding your answer. It's been voted down a bit, probably because it has a syntax error in the code (it's missing a semicolon after the global $wp_query) but also because it doesn't fully answer the question. It's a function, but the OP asked how to work this out in his header file - so it might need a little more explanation about what to put where. Again, welcome, glad to have you here! – Tim Malone Apr 17 at 22:07
Tim, Thanks for comment ! I reviewed my answer. – Sergey Repin Apr 19 at 5:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.