Wordpress. I've got a handful of pages, each with children -- varying depths.
Let's say it's like this:
+about
-- page1
-- page2
+stuff
-- page1
--- sub-sub-page
-- page2
My problem: I want to set a graphic header for all the "about" pages, including all its children... and a different graphic header for all "stuff" pages and all its children.
I could do this using a custom field for each individual page, but I don't trust my users to remember to set this field.
I thought about adding to the page.php template and telling the page to find its parent top-level page to determine which "family" it's in, then set the header graphic that way...but I don't want to invest a ton of time (and run-time) resources traversing up the hierarchy.
Any ideas?
Much thanks in advance...
UPDATE:
Taking the code from below, I modified it to use outside of the Wordpress Loop (have not yet integrated the "default" value yet).
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$header_swf = get_post_meta($postid, 'header_swf', true);
if (!$header_swf) {
$parent = get_page($wp_query->post->post_parent); //array of values for this page's parent, directly above it
while (!$header_swf && $parent) {
$header_swf = get_post_meta($parent->ID, 'header_swf', true);
$parent = get_page($parent->post_parent); //new parent
}
}
?>