Using conditional tags in sidebar

by 4 replies
5
To display a couple of images in the sidebar only on the blog page of my WordPress site, I'm using this:

Code:
<?php if ( is_page('6') ) { ?>
<div id="border"><p><img src="http://mi-trale.org/wp-content/uploads/2011/04/filename1.jpg"/></p>
<div id="captions"><caption>caption text here</caption></div>

<p><img src="http://mi-trale.org/wp-content/uploads/2011/04/filename2.jpg"/></p>
<div id="captions"><caption>caption text here</caption></div>
<?php } ?>
It works fine for all the pages except for this blog page. (I installed WP on the root, but I assigned a static page as the home page and chose a different page to display the posts.) Does anyone know why it doesn't work on that page?
#programming #conditional #sidebar #tags
  • Try using...

    Code:
    <?php if ( is_home() ) { ?>
    In wordpress, is_home will only return true for the page specified to display your blog posts. It will not show the content on any individual blog posts, however.

    -Ryan
    • [ 1 ] Thanks
  • Thank you, thank you! It worked!
    • [2] replies
    • Main Page « WordPress Codex for more information.
      • [ 1 ] Thanks
    • It worked fine!

Next Topics on Trending Feed

  • 5

    To display a couple of images in the sidebar only on the blog page of my WordPress site, I'm using this: Code: <?php if ( is_page('6') ) { ?> <div id="border"><p><img src="http://mi-trale.org/wp-content/uploads/2011/04/filename1.jpg"/></p> <div id="captions"><caption>caption text here</caption></div> <p><img src="http://mi-trale.org/wp-content/uploads/2011/04/filename2.jpg"/></p> <div id="captions"><caption>caption text here</caption></div> <?php } ?> It works fine for all the pages except for this blog page. (I installed WP on the root, but I assigned a static page as the home page and chose a different page to display the posts.) Does anyone know why it doesn't work on that page?