Is it possible within the current theme file naming hierarchy to define a template for for all pages that are a child of a specific page? For example, in this navigation:
About Us
- Contact
- Who We Are
- Message Statement
Is there any way to just make a theme file named something like:
page-about-us-all.php
That would automatically be applied to all pages that are children of About Us?
UPDATE
I went with a modified version of what Bainternet had suggested. Here's the descendant function I ended up with:
function is_descendant($ancestor, $tofind = 0) {
global $post;
if ($tofind == 0) $tofind = $post->ID;
$arrpostids = get_post_ancestors($tofind);
$arrpostslugs = array();
foreach($arrpostids as $postid) {
$temppost = get_post($postid);
array_push($arrpostslugs, $temppost->post_name);
}
return (in_array($ancestor, $arrpostids) || in_array($ancestor, $arrpostslugs));
}
// Example use:
is_descendant('about-us');
is_descendant(123);
is_descendant('about-us', 134);
This allows me to verify it's a descendant using either the ID of the parent or the slug. I was concerned that using only the ID might lead to a problem if a parent page had been accidentally trashed there would be no good way to get that to work again without having to edit the Theme files. With the slug at least there's the option of just hopping in and making a new page with the same slug and hierarchy.
is_descendant()
: there are some things that should be avoided regarding speed: count, array checking and other stuff that "does" something else than just representing a value processed before, inside if/elseif/for/foreach/while - anyway: faved & +1