Title: Menu depth problem
Last modified: August 19, 2016

---

# Menu depth problem

 *  [Dstep](https://wordpress.org/support/users/dstep/)
 * (@dstep)
 * [15 years ago](https://wordpress.org/support/topic/menu-depth-problem/)
 * Hello everyone,
 * I’ve been struggling with a menu problem all day, and I can’t seem to find any
   solution on the internet.
 * I have 2 menus on my WordPress site that look like this: [http://i51.tinypic.com/t8uipx.jpg](http://i51.tinypic.com/t8uipx.jpg).
 * I have three pages with the following hierarchy:
    – Parent 1 – Child 1 – Baby
   1
 * The problem is that the top menu shows both Child and Baby pages, while I only
   want it to show Parent and Child pages. The sidebar menu shows Child and Baby
   pages, while I only want it to show Baby pages.
 * This is the code that I use for the top menu:
 *     ```
       <div id="navigation">
                           <!-- Begin navigation -->
   
       	                <ul>
       <?php wp_list_pages('title_li=&depth=1'); ?>
       </ul>
   
       <?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="child">
       <?php echo $children; ?>
       </ul>
       <?php } else { ?>
       <?php } ?>
       					<!--<ul>
                               <li><a href="<?php echo get_option('home'); ?>/">Blog</a></li>
                               <?php wp_list_pages('title_li=&depth=1'); ?>
       	                </ul>-->
                       </div><!--End navigation -->
       ```
   
 * This is the code that I use for the sidebar menu:
 *     ```
       <div id="sidebar">
                   <?php
       if (is_page( )) {
         $page = get_query_var('page_id');
   
         $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
         if ($children) {
           $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
         }
       }
       echo $output;
       ?>
   
                           </div>
       ```
   
 * Can anyone please help me with this issue? I would greatly appreciate it.
 * Thanks!

The topic ‘Menu depth problem’ is closed to new replies.

## Tags

 * [depth](https://wordpress.org/support/topic-tag/depth/)
 * [menu](https://wordpress.org/support/topic-tag/menu/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)

 * 0 replies
 * 1 participant
 * Last reply from: [Dstep](https://wordpress.org/support/users/dstep/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/menu-depth-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
