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

1 Answer 1

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

Your Answer

 
discard

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.