Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm new one for Wordpress. I need to check in header file as, is it Blog Page or not?

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

share|improve this question
add comment

4 Answers 4

up vote 1 down vote accepted

There is a list of conditional tags here - http://codex.wordpress.org/Conditional_Tags

share|improve this answer
add comment

You can use

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

Do stuff here

<?php } ?>
share|improve this answer
add comment

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

function is_blog () {
global  $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post')  ) ? true : false ;

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
add comment

Depending what you're trying to accomplish, you could also use the have_posts() conditional tag combined with if/else statement as shown below.

<?php if( have_posts() ) { ?>
  <p>This page has posts</p>
<?php } else {
  echo '<p>This page does not have posts</p>';
share|improve this answer
add comment

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.