Support » Themes and Templates » How do I implement conditions for elements?

  • Hey there,

    I’ve just started working on a new wordpress theme and I would like to include, next to each post, a category icon.
    The problem is that i don’t know exactly how to state the conditions (for example, all articles under the category 1 should have a big 1 logo for an icon, and so on for the next ones).

    Can you please help me?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi


    Forum Moderator

    And what if a post is in more than 1 category?

    Then I’ll assign an icon that corresponds to “multiple categories”.

    Do you know the solution to my problem?



    Forum Moderator

    <?php if(in_category('1')) $cat_image = cat1.gif;
    elseif(in_category('2')) $cat_image = cat2.gif;
    else $cat_image = multi-cat.gif;?>

    It’s a bit clumsy, though, and could be difficult to maintain.

    Thanks, i’ll give this a go as soon as possible.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I implement conditions for elements?’ is closed to new replies.