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 have some code that I would only like to be displayed on the sidebar when on the blog (the page that displays the posts).

Now I am using this code...

<?php if(is_page('37')) { ?> 
...Show code...
<?php } ?>

The strange thing is if I enter any other page ID, it works as expected and shows the code, however, when I enter ID 37 (blog page), the code does not show on the blog page. Do I need to do something differently as it is my main post page and not a regular page?

P.S By Post page, I mean the page I have set in the wordpress admin where posts should be displayed.

wp-admin reading settings

share|improve this question
Got it! Turns out I should be using is_home which seems to work. – Adam Dec 8 '12 at 21:39
Adam, is the screenshot correct? Also, answer your own Question (and mark it as the correct one in a couple of days), so it doesn't remain in the Unanswered list. Would be nice if you added a summary from here: codex.wordpress.org/Conditional_Tags#The_Main_Page – brasofilo Dec 8 '12 at 21:50
yep will do. Yes the screenshot is correct, thanks. – Adam Dec 9 '12 at 0:19
up vote 0 down vote accepted

Got it! Turns out I should be using is_home which seems to work.

More info here.. http://codex.wordpress.org/Conditional_Tags#The_Main_Page

share|improve this answer

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.