Page-specific sub page navigation
-
Hi,
I’m trying to display sub navigation in my sidebar that shows the current page with a “current” class but this is indented beneath its parent link with its sibling links. But also I would like to display the parents siblings links too. So, essentially I want a parent > child > grandchild hierarchy navigation, but I can’t figure out the code for this. I have this so far:
<?php if ( is_page() ) { ?> <?php if($post->post_parent) { $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); }else{ $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); } if ($children) { $permalink = get_permalink($post->post_parent); ?><a href='<?php echo $permalink;?>'> <h2> <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> </h2></a> <ul class="sub-nav"> <?php echo $children; ?> </ul> <?php } } ?>
but if I am on the grandchild page, it only shows the child page as its parent page. I want it to still show the grandparent and the grandparents sibling links.
Sorry if this is quite confusing. :/
(I’ll upload images of the output I’m looking for if that will help…)
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Page-specific sub page navigation’ is closed to new replies.