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

  • 1
    Got it! Turns out I should be using is_home which seems to work.
    – Adam
    Dec 8 '12 at 21:39
  • 1
    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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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