• I hope I can explain this in a way that makes sense to all.

    I have 5 links down the side of my site like so:

    Link 1
    Link 2
    Link 3
    Link 4
    Link 5

    Under “Link 2” I have 3 Child Links

    Link 1
    Link 2
    Child 1
    Child 2
    Child 3
    Link 3
    Link 4
    Link 5

    What I am after is I want only the Parent Links displayed as default. When a Parent Link is selected that has children I want the Children to show up…but the Parents links to remain there as well.

    I have this code currently and the Parents disappear when a Child is selected and I can;t figure out how to fix this.

    <?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) { ?>
    <ul id=”navigation”>
    <?php echo $children; ?>

    <?php } ?>

    Any help is much appreciated.

Viewing 1 replies (of 1 total)
  • Try something like:

    <?php
    $my_pages = wp_list_pages('title_li=&depth=1&echo=0');
    if (is_page()) {
    	$this_page = $post->ID;
    	if ($post->post_parent) $this_page= $post->post_parent;
    	$children = get_page_children($this_page, get_pages());
    	if($children) {
    		$my_pages .= "<li>\n".'<ul class="subpages">';
    		foreach($children as $child) {
    			$my_pages .= wp_list_pages('title_li=&include='.$child->ID.'&echo=0');
    		}
    		$my_pages .= '</ul></li>';
    	}
    }
    echo $my_pages;
    ?>
Viewing 1 replies (of 1 total)

The topic ‘Another PArent Child Navigation Question’ is closed to new replies.