(I haven't tested this, I hope it works :-))
Insert this code somewhere at the beginning of your template (or in your theme's functions.php file):
Code:
<?php
$myslugs = array('page1','page2','page3'); // <-- edit this
if (in_array(get_parent(0),$myslugs)) {
$pageorparent = get_parent(0);
} elseif (in_array(get_page_slug(0),$myslugs) {
$pageorparent = get_page_slug(0);
} else {
$pageorparent = 'default';
}
?>
Now, to display the component:
Code:
<?php get_component('comp-'.$pageorparent); ?>
And to display the header image:
Code:
<img src="<?php get_site_url(); ?>data/uploads/header-<?php echo $pageorparent; ?>.png">
(change
.png to your preferred image file extension)
-
page1 and its child pages will display component
comp-page1 and header image
header-page1.png
- if a page is not in the list (
$myslugs), component
comp-default and image
header-default.png will be displayed.