Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2221

    First, how do I get the sub menu to display just the pages in the site (on the blog pages I’ll show the categories, etc.) and second, how do I get the sub menu to expand to show the other child pages below a parent page? Third, how do I get the sub menu (side menu) to reflect the top navigation?

    #37173

    Hey,

    Assuming by “sub menu” you mean the drop down as per the demo:

    1.) Using the WP Custom Menus function added in WP 3.0 you can list the pages in whichever order you choose.

    2.) Again using the WP Custom Menus :)

    3.) You can create a separate WP Custom Menu and add this as a widget to the sidebar.

    Display supports WP Custom Menus in version 2.0 – you would need to upgrade by downloading the latest version from Theme Forest if you run an older version.

    Let me know if this needs further clarification.

    James

    #37174

    #2) I was referring to the side menu. I’d like to get the php code to only show the pare and child pages of just the parent page and not have to manually create a custom side menu.

    #37175

    Hey,

    you can use following code to display child pages in your sidebar:

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul id="subnav">
    <?php echo $children; ?>
    </ul>
    <?php } ?>

    Just copy this code into sidebar.php – i.e. replace:

    <div class='box box_small'>
    <h3>Categories</h3>
    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=0'.$exclude); ?>
    </ul>
    </div>

    with:

    <div class='box box_small'>
    <h3>Categories</h3>
    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=0'.$exclude); ?>
    </ul>
    </div>

    <div class='box box_small'>
    <h3>Pages</h3>

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul id="subnav">
    <?php echo $children; ?>
    </ul>
    <?php } ?>
    </div>

    #37176

    I tried adding the extra div and code in my sidebar.php and it didn’t change the side navigation at all. I’m trying to get it to only display the child pages for the parent page I’m in…

    <div class=’box box_small’>

    <h3>Categories</h3>

      <?php wp_list_cats(‘sort_column=name&optioncount=0&hierarchical=0′.$exclude); ?>

    </div>

    <?php

    if($post->post_parent)

    $children = wp_list_pages(“title_li=&sort_column=menu_order&child_of=”.$post->post_parent.”&echo=0″);

    else

    $children = wp_list_pages(“title_li=&sort_column=menu_order&child_of=”.$post->ID.”&echo=0″);

    if ($children) { ?>

    <ul id=”subnav”>

    <?php echo $children; ?>

    <?php } ?>

    #37177

    Hey,

    please use following code to display child pages only:

    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul id="subnav">
    <?php echo $children; ?>
    </ul>
    <?php } ?>

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Sub Menu: Show Parent & Child Pages’ is closed to new replies.