I’ve made some progress – I can get it almost to work! The problem is that it is now showing all the different intoductions under one another, rather than just showing the one according to the page/child I am on.
Here’s the header.php code:
<!-- About us -->
<?php if (is_superparent('2')) : ?>
<h1>About us</h1>
<p>The essentials about our purpose, who we work with, how we're organised, our policies, history - and how to contact us when it's not an emergency.</p>
<?php endif; ?>
<!-- Hill safety -->
<?php if (is_superparent('23')) : ?>
<h1>Hill safety</h1>
<p>Prevention is better than rescue. We have put together some resources for your use on this page to help you be self reliant in wild and remote places.</p>
<?php endif; ?>
<!-- Support us -->
<?php if (is_superparent('16')) : ?>
<h1>Support us</h1>
<p>As a charity wholly serviced by unpaid volunteers, we rely on your all round support to keep operating. These are the different ways you can contribute.</p>
<?php endif; ?>
Here’s the functions.php code:
function is_superparent($parentid) {
if (is_page('2')) return true;
else {
while ($parentid) {
$page = get_page($parentid);
$parentid = $page->post_parent;
if ($parentid=="2") return true;
}
return false;
}
}
Can anyone help?