• This seems like it should be simple. Here’s what I think the code should do – I just can’t figure out the syntax.

    IF CATEGORY = (CATEGORY NUMBER)

    INSERT SIDEBAR 1

    ELSE

    INSERT SIDEBAR 2

    Thank you for any advice…

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is what you need: Conditional_Tags

    Thread Starter dredub38

    (@dredub38)

    I shall name my first born “moshu”!

    Be careful, it means “old man” 🙂

    Thread Starter dredub38

    (@dredub38)

    Perhaps “billy” or “steve”…

    I think I’m close. Here is the code I’m trying in single.php

    <?php
    if (is_category('13'))
    {
    echo 'yes ';
    } else {
    echo 'no ';
    }
    echo 'either way';
    ?>

    That looks like it should work, but I always get the “no”. Am I doing something that is obviously wrong?

    You are using the wrong conditional – on single.php use in_category.
    And I really don’t understand the last line… when to echo ‘either way’? (although I am not a coder!)

    Thread Starter dredub38

    (@dredub38)

    That last line was superfluous.

    It’s amazing how changing one freakin’ letter made it work. I am going to write this one down and sleep with it under my pillow so I remember it.

    Moshu, I appreciate your help with this!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Identify Category of Post, Insert Code’ is closed to new replies.