Title: problem with menu depth
Last modified: August 19, 2016

---

# problem with menu depth

 *  [agatha83](https://wordpress.org/support/users/agatha83/)
 * (@agatha83)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/problem-with-menu-depth/)
 * i tried to set depth to 1 to stop the sub sub menu categories from displaying
   whilst being in the main menu but the problem is that now even when i click on
   the sub sub menu categories’ parent they are not being displayed anymore.
    i’m
   new to php and i hope someone can help me.
 * here’s the code
 *     ```
       <?php
       }
       if ( function_exists('register_sidebar_widget') )
           register_sidebar_widget(__('Links'), 'widget_techdesigns01_links');	 
   
       // List Subpages - Code from a plugin by Rob Miller (http://robm.me.uk/). Thanks Rob!
       function list_subpages_techdesigns01($return = 0) {
       global $wpdb, $post;
       $current_page = $post->ID;
       while($current_page) {
       $page_query = $wpdb->get_row("SELECT ID, post_title, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
       $current_page = $page_query->post_parent; }
       $parent_id = $page_query->ID;
       $parent_title = $page_query->post_title;
       if($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status = 'publish'")) {
       echo'<div class="menuheader"></div><div class="menucontent"><h5 class="menunav"><span>Navigation</span></h5><ul>';
       $html = wp_list_pages("child_of=$parent_id&depth=$depth&echo=".(!$return)."&title_li=0&sort_column=menu_order");
       echo'</ul></div><div class="menufooter"></div>'; }
       if($return) {
       return $html;
       } else {
       echo $html; } }
       ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [jon](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/problem-with-menu-depth/#post-1319689)
 * I see you using the variable $depth, but I don’t see you setting its value anywhere.
   Or is that in code you did not include above?
 * The simplest way to solve that problem is to remove the $depth and replace it
   with 1 as in `&depth=1&echo`
 *  Thread Starter [agatha83](https://wordpress.org/support/users/agatha83/)
 * (@agatha83)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/problem-with-menu-depth/#post-1319690)
 * sorry my fault i copied in the original code
 * i have done that here, like you said
 *     ```
       wp_list_pages("child_of=$parent_id&depth=1&echo=".(!$return)."&title_li=0&sort_column=menu_order");
       echo'
       ```
   
 * but it just resulted in the sub sub categories not being displayed at all anymore
 *  Thread Starter [agatha83](https://wordpress.org/support/users/agatha83/)
 * (@agatha83)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/problem-with-menu-depth/#post-1319696)
 * does anyone have an idea how to fix this?

Viewing 3 replies - 1 through 3 (of 3 total)

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

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [agatha83](https://wordpress.org/support/users/agatha83/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/problem-with-menu-depth/#post-1319696)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
