Title: Conditional tag in widget
Last modified: August 21, 2016

---

# Conditional tag in widget

 *  [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * (@crackingace)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/)
 * Hi,
 * I’ve been looking for an answer but can’t find one.
 * I have a widget with a few images in it. I want to make it so that some of them
   don’t appear on certain categories.
 * I found out about the conditional tag but it doesn’t seem to be working in the
   widget.
 * Is there something else I can use or am I doing it wrong?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376211)
 * PHP doesn’t work in widgets generally. Have you had a look at [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)
 *  Thread Starter [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * (@crackingace)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376363)
 * I’ll check that out. Thanks!
 *  Thread Starter [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * (@crackingace)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376444)
 * Unfortunately that plugin is no good. It hides whole widgets. I just want to 
   hide parts of one.
    I tried separating the pieces out into individual widgets,
   but that leaves large gaps between them.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376445)
 * what widget type?
    does each image have its own specific CSS class? does your
   theme use `body_class()`
 * can you post a link to your site?
 * also consider to replace your widget with a ‘php in widget’ via a plugin; [http://wordpress.org/plugins/search.php?q=php+in+widget&sort=](http://wordpress.org/plugins/search.php?q=php+in+widget&sort=)
 *  Thread Starter [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * (@crackingace)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376446)
 * I’m just using a standard theme and standard widgets at the moment.
 * [http://www.crackingace.com](http://www.crackingace.com)
 * What I’m trying to do is have some of the top tag image links appear in certain
   categories and not in others.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376448)
 * try to add a unique CSS class to each image tag in your textwidget;
 * example:
    `<a href=http://www.crackingace.com/tag/batman/><img class="batman-
   im" src=http://crackingace.com/caimages/batman_button.png /></a>`
 * then use CSS to hide the image in a category:
 * example:
 * `.category-alpha .batman-img { display: none; }`
 * ref [http://codex.wordpress.org/Function_Reference/body_class](http://codex.wordpress.org/Function_Reference/body_class)
 *  Thread Starter [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * (@crackingace)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376449)
 * Thanks for the suggestions.
 * The php plugins don’t seem to be working for me. Not sure why.
 * Could you explain the CSS option to me please? I haven’t used it before, so not
   sure what to do with it.

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

The topic ‘Conditional tag in widget’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [CrackingAce](https://wordpress.org/support/users/crackingace/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/conditional-tag-in-widget/#post-4376449)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
