I've been reading around a lot of the discussion following sub pages and sub-sub pages, but I haven't quite found the answer I'm looking for (most of the posts seem to concern wp_list_pages showing a proper nav list when on page, child, or sub-child...)
I think I know roughly how you would do this in plain English, but my PHP isn't that strong.
Problem
I need to define a variable for templating reasons that if you are on a page, any of its sub-pages, or any of those sub-page's sub-pages.. and so on.
Following the codec example I have thus far got:
<?php
if (is_page('20') || $post->post_parent=="20") {
$sidebar_call = 1;
} elseif (is_page('34') || $post->post_parent=="34") {
$sidebar_call = 2;
} elseif (is_page('11') || $post->post_parent=="11") {
$sidebar_call = 3;
} elseif (is_page('12') || $post->post_parent=="12") {
$sidebar_call = 4;
} else {
$sidebar_call = "default";
}
?>
As I expected, this works fine on any of the above pages or their sub-pages, but when you get to a sub-sub-page the variable is assigned the default value.
I can imagine that I need to create an array (as can now be done in 2.5), but am not sure how to go about it.
I know there is a function for get_children, but I haven't found any documentation on how that works (and whether it gets children of the children!).
My English version of the code would be:
<?php
if (is_page('20') || (is_page(get an array of all children and sub children of page 20...) {
$sidebar_call = 1;
} elseif (is_page('34') || (is_page(get an array of all children and sub children of page 34...) {
$sidebar_call = 2;
} etc...
?>
However I'm not sure exactly how to make this happen....
Any ideas?