WordPress.org

Ready to get started?Download WordPress

Forums

Navigation/Sub Navigation and how it displays (2 posts)

  1. richgcook
    Member
    Posted 1 year ago #

    Hi folks,

    I've been trying to figure this out for a few days now but have become a little stumped. I'm going to do my best to explain this, but do let me know if I've managed to confuse this even further.

    I have navigation on the site, parent pages with child pages etc. The code for this I have included below. What i want is the parent pages to be displayed across the whole site, which current works with the wp_nav_menu code I have set up. The complicated part, for me at least, is setting up how the child pages works. If you click on a parent page, I'd like the child pages for this parent page to be displayed on the right, which is what the ul=sub-navigation is for. The works, but when you click on a child page, it disappears. I'd like for the sub navigation to stay for whichever child page you are on for that parent. If you click on a different parent page, it changes to display it's child pages.

    A good example of how this should work is shown here: http://goo.gl/zW1YH

    <?php wp_nav_menu( array( 'container' => 'nav', 'fallback_cb' => 'starkers_menu', 'theme_location' => 'primary' ) ); ?>

    and

    <ul class="sub-navigation">
    				<?php
    				$parent_page = get_page_by_title( 'Home' );
    				wp_list_pages( 'title_li=&depth=1&child_of=' . $parent_page->ID );
    				?>
    				</ul>
    			</div>
    			<div class="grid_5">
    				<?php
    				  $children = wp_list_pages('title_li=&sort_column=menu_order&child_of='.$post->ID.'&echo=0');
    				  if ($children) { ?>
    				  <ul class="sub-sub-navigation">
    				  <?php echo $children; ?>
    				  </ul>
    				  <?php } ?>

    Many thanks in advance.

    -R

  2. richgcook
    Member
    Posted 1 year ago #

    I can't seem to edit the post, but my navigation is actually set up like this:

    <div class="grid_3">
    				<ul class="sub-navigation">
    				<?php
    				$parent_page = get_page_by_title( 'Home' );
    				wp_list_pages( 'title_li=&depth=1&child_of=' . $parent_page->ID );
    				?>
    				</ul>
    			</div>
    			<div class="grid_5">
    				<?php
    				  $children = wp_list_pages('title_li=&sort_column=menu_order&child_of='.$post->ID.'&echo=0');
    				  if ($children) { ?>
    				  <ul class="sub-sub-navigation">
    				  <?php echo $children; ?>
    				  </ul>
    				  <?php } ?>
    			</div>

Topic Closed

This topic has been closed to new replies.

About this Topic