WordPress.org

Forums

Can sidebar pic appear only for a certain category? (4 posts)

  1. bylto
    Member
    Posted 8 years ago #

    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!

  2. Dgold
    Member
    Posted 8 years ago #

    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.

  3. bylto
    Member
    Posted 8 years ago #

    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>
    ?>

  4. Dgold
    Member
    Posted 8 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic