Title: [Plugin: Widget Logic] Help with conditional statement
Last modified: August 20, 2016

---

# [Plugin: Widget Logic] Help with conditional statement

 *  [ryanoryan](https://wordpress.org/support/users/ryanoryan/)
 * (@ryanoryan)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/)
 * Hi,
 * I am trying to exclude a widget from pages, subpages and a category of posts.
 * This is the statement I have at the moment:
 * global $post; return ! (is_page(‘5’) || ($post->post_parent==”5″)) || is_single()&&
   in_category( ‘7’ ) ;
 * It is removing it correctly for pages and subpages but can’t get it to work on
   the posts?
 * Any idea where I am going wrong?
 * Thanks

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

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652594)
 * you need to bracket together
 * (is_single() && in_category(‘7’))
 *  Thread Starter [ryanoryan](https://wordpress.org/support/users/ryanoryan/)
 * (@ryanoryan)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652598)
 * Ah yes, thank you. had to change it slightly to work but you put me on the right
   track, working code:
 * global $post; return ! (is_page(‘5’) || ($post->post_parent==”5″) || is_single()&&
   in_category( ‘7’ )) ;
 * Thanks again
 *  [CorgBrannon](https://wordpress.org/support/users/corgbrannon/)
 * (@corgbrannon)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652698)
 * How do you **exclude** a widget from one single page or a number of pages? Can’t
   seem to find it in the FAQs.
 * Thx
 *  Thread Starter [ryanoryan](https://wordpress.org/support/users/ryanoryan/)
 * (@ryanoryan)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652699)
 * You just add ! before hand.
 * e.g. ! (is_page(‘5’)
 *  Thread Starter [ryanoryan](https://wordpress.org/support/users/ryanoryan/)
 * (@ryanoryan)
 * [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652700)
 * ! (is_page(‘5’) )

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

The topic ‘[Plugin: Widget Logic] Help with conditional statement’ is closed to 
new replies.

## Tags

 * [conditional statement](https://wordpress.org/support/topic-tag/conditional-statement/)

 * 5 replies
 * 3 participants
 * Last reply from: [ryanoryan](https://wordpress.org/support/users/ryanoryan/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-widget-logic-help-with-conditional-statement/#post-2652700)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
