Title: How do I implement conditions for elements?
Last modified: August 19, 2016

---

# How do I implement conditions for elements?

 *  [C05T1N](https://wordpress.org/support/users/c05t1n/)
 * (@c05t1n)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/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](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-implement-conditions-for-elements/#post-1196838)
 * And what if a post is in more than 1 category?
 *  Thread Starter [C05T1N](https://wordpress.org/support/users/c05t1n/)
 * (@c05t1n)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-implement-conditions-for-elements/#post-1196978)
 * Then I’ll assign an icon that corresponds to “multiple categories”.
 * Do you know the solution to my problem?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-implement-conditions-for-elements/#post-1197044)
 *     ```
       <?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.
 *  Thread Starter [C05T1N](https://wordpress.org/support/users/c05t1n/)
 * (@c05t1n)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-implement-conditions-for-elements/#post-1197089)
 * 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.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [Conditions](https://wordpress.org/support/topic-tag/conditions/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [icons](https://wordpress.org/support/topic-tag/icons/)

 * 4 replies
 * 2 participants
 * Last reply from: [C05T1N](https://wordpress.org/support/users/c05t1n/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-implement-conditions-for-elements/#post-1197089)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
