Return to Snippet

Revision: 42423
at March 4, 2011 22:57 by mesh606


Initial Code
<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);
				$root=count($ancestors)-1;
				$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 } ?>

Initial URL

                                

Initial Description
use this in the sidebar to show a top level page with child pages persistently

Initial Title
Show Top Level and Child Pages in Wordpress

Initial Tags
wordpress

Initial Language
PHP