Title: Is this possible using conditional logic?
Last modified: August 20, 2016

---

# Is this possible using conditional logic?

 *  [evolution2](https://wordpress.org/support/users/evolution2/)
 * (@evolution2)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/is-this-possible-using-conditional-logic/)
 * I would like to display widget on a single post ONLY is that post is assigned
   to a certain category. Is this possible using conditional logic?
 * For instance, if my site is about “New Cars”, I want an ad for Chevy to only 
   be displayed on posts assigned to my “Chevy” category and not “Ford” and vice
   versa.

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

 *  [w.davis](https://wordpress.org/support/users/wdavis-1/)
 * (@wdavis-1)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/is-this-possible-using-conditional-logic/#post-3029512)
 * Im very new at everything web programing, but you should be able to do this.
 * Try this inside your loop:
    <?php $id = $query->post->cat; if ($id == (category
   goes here)){ ?> <div id=”chevy_add”> code for chevy add </div> }
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/is-this-possible-using-conditional-logic/#post-3029514)
 * conditional tags [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)
 * for instance, use:
 * `in_category()`
 * possibly in context of a conditional widget plugin, such as [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)

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

The topic ‘Is this possible using conditional logic?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/is-this-possible-using-conditional-logic/#post-3029514)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
