OHow to only list grandchildren when on their direct parent page
-
Hi,
I am trying to find out if it’s possible to list just the children of a page that is already a child, only when you are on that first child page;
The site has 3 tiers, as follows:
Home
Work
Profile
Media
-Radio
–Programme1
–Programme2
-Print
–Publication1
–Publication2
ContactWhen clicking on ‘Media’ I am listing the immediate ‘Child’ pages (Radio & Print), and have managed to *not* show the grandchildren at this stage, by using the following code:
<div id="mainnav"> <ul> <?php wp_list_pages('sort_column=menu_order&title_li=&depth=1'); ?> </ul> </div> <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1"); if ($children) { ?> <div id="subnav"> <ul> <?php echo $children; ?> </ul> </div> <?php } ?>
I’d like to show ‘Programme1 & Programme2’ only when clicking on ‘Radio’, and ‘Publication1 & Publication2’ only when clicking on ‘Print’
Is this possible?
I’m sorry if it’s been answered already, I have been looking through the forums for some time, but haven’t found anyone asking quite the same question (I don’t think!)Thank you in advance for any help.
- The topic ‘OHow to only list grandchildren when on their direct parent page’ is closed to new replies.