WordPress.org

Ready to get started?Download WordPress

Forums

Creating Sub Page Menu (5 posts)

  1. saneef
    Member
    Posted 5 years ago #

    I need to create a menu like this on top of the page:

    ---------------------------------------
    Main Menu: Page 1 | Page 2 | *Page 3 | Page 4
    ---------------------------------------
    Sub Menu: ChildPage31 | ChildPage32 | ChildPage34
    ---------------------------------------

    If i'm in page "Page 3", I have to highlight "Page 3" and list all its subpages.

    And again if i'm in a child page say 'ChildPage31' i have to highlight the parent page link "Page 3"

    Please show some light code this thing using WP!

    Thanks

  2. satmandue
    Member
    Posted 5 years ago #

    Hey, this is a BIG bump? Any help. Cuz I would like to use a sub menu with dynamic highlighting. Man, this must be the WordPress weakness of the century.

  3. perywinkle
    Member
    Posted 5 years ago #

    Found this link for listing of sub pages:
    http://codex.wordpress.org/Template_Tags/wp_list_pages
    "List subpages even if on a subpage "

    I've also been using Fold page listing pages. Which is similar, but what you describe.
    http://www.webspaceworks.com/resources/wordpress/31/

    Mic

  4. perywinkle
    Member
    Posted 5 years ago #

    This seems to work for me:

    Code:

    <!-- Main Menu -->
    <div id="mainmenu">
    	<ul>
    	<?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
    	</ul>
    </div><!-- / Mainmenu -->
    
    <?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) { ?>
    
    <!-- Sub Menu -->
    <div id="submenu">
      <ul>
      <?php echo $children; ?>
      </ul>
      </div> <!-- / Sub Menu -->
    
      <?php } ?>

    CSS additions:

    /* =Current --------------- */
    .current_page_item{}
    .current_page_item a{
    	background: #FFFFFF;
    }
    .current_page_parent a{
    	background: #FFFFFF;}
    .current_page_ancestor a{}

    You likely have your menu's li displayed as 'inline', if not then you'll want to add that too.

  5. fldtrace
    Member
    Posted 4 years ago #

    Here you can find a tutorial regarding displaying dynamic menu pages

Topic Closed

This topic has been closed to new replies.

About this Topic