Support » Themes and Templates » Can sidebar pic appear only for a certain category?

  • I like to write about many topics related to personal development at my blog. One category is physical fitness. I would like a pic of me in the sidebar to only appear there for posts that are within the fitness category. Is this possible? What code would I use and where should I put it?

    Thanks for any help you can give me!

Viewing 3 replies - 1 through 3 (of 3 total)
  • you need to wrap a conditional code around the picture code, in your sidebar.php

    This page will help you get the exact code,
    http://codex.wordpress.org/Conditional_Tags

    the basic code you need is,
    is_category('6')

    hopefully someone else can tell you exactly how to write it out to make it work. That is the conditional tag you need, but it needs a bit of PHP stuff before/after, and wrap it around the image code.

    Thanks very much DGold!

    Would it be something like this? Can anyone help me on this?

    <?php
    if (is_category(6)) {
    <p align=center>
    <img src=”/wp-content/themes/xxxxxxxxx.jpg” width=”70″ height=”170″>
    </p>
    ?>

    It’s something like that… but that doesn’t look right to me… but I can’t really tell you how to fix it…

    One hint is to use back-ticks if you are posting Code here on the forums, makes it look better

    Someone else can help here?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can sidebar pic appear only for a certain category?’ is closed to new replies.