Title: widget logic help
Last modified: August 19, 2016

---

# widget logic help

 *  [theodion](https://wordpress.org/support/users/theodion/)
 * (@theodion)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/)
 * I cant get widget logic to work as i want.
 * i want to view a widget on siderbar if:
    1. we view a post in one of the categories
   1,2,3 OR 2. we view one of the categories 1,2,3 OR. 3. we view the page 575
 * so i made the following query for widget logic:
    `((is_single(array(in_category(
   array(1,2,3))))) || is_category(array(1,2,3)) || is_page(575))`
 * the is single does not work, but the other 2 conditions (is_category,is_page)
   work perfectly.
 * what i’m doing wrong with is_single?
 * thanks

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656170)
 * I think this is what you want:
 * `((is_single() && in_category(array(1,2,3))) || is_category(array(1,2,3)) || 
   is_page(575))`
 *  Thread Starter [theodion](https://wordpress.org/support/users/theodion/)
 * (@theodion)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656177)
 * it doesnt work 😐
 * i converted all my queries like the above ^^ but (is_single() && in_category(
   array(1,2,3))) does not work…
 * 1.
 *     ```
       ((is_single() && in_category(array(6,35,36,37,38))) || is_category(array(6,35,36,37,38)) || is_page(575))
       ```
   
 * 2.
    `((is_single() && in_category(array(24,47,48,50,51))) || is_category(array(
   24,47,48,50,51)) || is_page(563))`
 * 3.
    `((is_single() && in_category(array(23,27,28,29,30,31,52,53,54))) || is_category(
   array(23,27,28,29,30,31,52,53,54)) || is_page(478))`
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656187)
 * You may need to supply the post ID in the in_category call.
 *  Thread Starter [theodion](https://wordpress.org/support/users/theodion/)
 * (@theodion)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656195)
 * i already tried that. no luck.
 * come one guys… no one can help me solve this?
 *  Thread Starter [theodion](https://wordpress.org/support/users/theodion/)
 * (@theodion)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656198)
 * > You may need to supply the post ID in the in_category call.
 * i tried in_category(6,770)
 * View the widget menu if the post with id 770 belongs to category 6.
    this is 
   true but the widget does not appear…
 *  Thread Starter [theodion](https://wordpress.org/support/users/theodion/)
 * (@theodion)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656199)
 * to clear the above:
 * i’m viewing the post 770 which belongs to category 6
 * i supplied widget custom menu with this in_category(6,770)
 * and the widget does not appear…
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656217)
 * You say the widget shows when is_category is true, and when is_psge(575) is true,
   so narrow down the part that is not working. First try:
 * `((true && in_category(array(6,35,36,37,38))) || is_category(array(6,35,36,37,38))
   || is_page(575))`
 * If that works, then is_single() is returning false. If not, in_category(…) is
   returning false.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656272)
 * [http://codex.wordpress.org/Template_Tags/in_category](http://codex.wordpress.org/Template_Tags/in_category)
 * in the case of calling in_category with 2 parameters, the 2nd one is the post
   ID, so in_category(6,770) will be always false or always true, regardless of 
   what post/page/etc you are looking at.
 * if you are absolutely sure that post 770 is in category 6, then that should always
   be true and that widget will always show. so i can’t explain what you are seeing.
 * the form is_single() && in_category(array(1,2,3)) should do what you want. if
   it’s not, see if it IS working when you switch to a default theme – just to check
   if the theme code is interfering with WP stuff behind the scenes that alters 
   the evaluation of those conditional tag.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656273)
 * another suggestion – try supplying the category slug instead of the ID

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

The topic ‘widget logic help’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 3 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/widget-logic-help-1/#post-1656273)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
