Support » Fixing WordPress » Subnav on single posts

  • Hello, I’m trying to build a subnavigation for a WP powered website. I’m using the bare Starkers theme which should be based on Twenty-Ten.

    I’ve managed to get a subnav listing all children pages, using the tags provided in the docs, so now I have the following code inside my header.php template:

    <?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 && is_page()) { ?>
    
    	<ul id="subnav">
    		<?php echo $children; ?>
    	</ul>
    <?php } else { ?>
    <?php } ?>

    So now if I’m on the parent page I have a nice subnav listing all my children pages, and if I’m on a child page I get all the other children pages listed – nice! But my problem is that if I’m on a post single page, ie. mysite.com/parent/child/yyyy/mm/post-title/ then no subnavigation bar is shown.
    How can I get a subnav on a single post page? Is it possible to achieve this without any plug-in?
    I’m a complete newbie, and I don’t know much about php or wp-tags, so this may be a silly question, but I’ve searched the forum and didn’t find any clue…

  • The topic ‘Subnav on single posts’ is closed to new replies.