/ Published in: PHP

use this in the sidebar to show a top level page with child pages persistently
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<ul><?php $parent_title = get_the_title($post->post_parent);?> <li><a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?></a></li></ul> <?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $parent = $ancestors[$root]; } else { $parent = $post->ID; } $children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0"); if ($children) { ?> <ul id="subnav"> <?php echo $children; ?> </ul> <?php } ?>
Comments
