Title: Widget Logic
Last modified: August 19, 2016

---

# Widget Logic

 *  [arizonapain.com](https://wordpress.org/support/users/arizonapaincom/)
 * (@arizonapaincom)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/widget-logic-2/)
 * trying to get widgets to show up under parents. example
 * [http://arizonapain.com/pain-center/pain-treatments/](http://arizonapain.com/pain-center/pain-treatments/)
 * everything under that page I want a widget. But NOT on that page.
    I could have
   a really long code of is_page (‘x’) && is_page(‘x’) ect.. but there has to be
   a quicker way!!!
 * I have also set up a function : using is_subpage (‘x’) but this put widget the
   page I dont’ want to so I added exclude and that killed it??? HELP!!!!
 * unction is_subpage() {
    global $post; // load details about this page if ( is_page()&&
   $post->post_parent ) { // test to see if the page has a parent $parentID = $post-
   >post_parent; // the ID of the parent is this return $parentID; // return the
   ID } else { // there is no parent so… return false; // …the answer to the question
   is false }; };

Viewing 1 replies (of 1 total)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/widget-logic-2/#post-1585371)
 * Looks like you were close with your function – but it’s a little off in what 
   it returns for what you are actually trying to do. There are a couple of examples
   on
 * [http://wordpress.org/extend/plugins/widget-logic/other_notes/](http://wordpress.org/extend/plugins/widget-logic/other_notes/)
 * that should work for you though. Something like:
 * global $post; return (in_array(77,get_post_ancestors($post))); — WP pages are
   descendents (children, grandchildren etc) of page 77
 * or
 * global $post; return ($post->post_parent==”13″); — pages that’s are direct childred
   of page 13

Viewing 1 replies (of 1 total)

The topic ‘Widget Logic’ is closed to new replies.

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/widget-logic-2/#post-1585371)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
