Widget Logic
-
trying to get widgets to show up under parents. example
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
};
};
-
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/
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
The topic ‘Widget Logic’ is closed to new replies.