Subpages in Menu Editor not Nesting

admin2025-06-04  3

I am building a website for a public school district. All of our school buildings have common pages with the same name (i.e. Library, Nurse, Attendance, etc) that are nested under their parent building's page. While trying to update our site navigation, I've noticed that for some reason the Menus -> Pages -> View All area is not nesting the building pages under their building and is instead listing them alphabetically.

The odd thing is, I have nested pages set up in other areas of the site and they do nest themselves on the list.

Am I missing something? I can't find anything different about the way I nested the pages that do display properly vs those that don't. I double checked the nested pages and they have their building listed as their parent.

I find this extremely frustrating. Unless I go in and edit all of the pages under a specific building to force them into the recent list I have no idea which page is which.

  • I do NOT want to add the building name to each page title.
  • These pages are nested 3 levels deep (Schools -> Building Name -> Page Name)

If there isn't a way to fix the way the list displays, is there maybe a way to add the parent page's name to the page name? Or another way to build the menus?

I am building a website for a public school district. All of our school buildings have common pages with the same name (i.e. Library, Nurse, Attendance, etc) that are nested under their parent building's page. While trying to update our site navigation, I've noticed that for some reason the Menus -> Pages -> View All area is not nesting the building pages under their building and is instead listing them alphabetically.

The odd thing is, I have nested pages set up in other areas of the site and they do nest themselves on the list.

Am I missing something? I can't find anything different about the way I nested the pages that do display properly vs those that don't. I double checked the nested pages and they have their building listed as their parent.

I find this extremely frustrating. Unless I go in and edit all of the pages under a specific building to force them into the recent list I have no idea which page is which.

  • I do NOT want to add the building name to each page title.
  • These pages are nested 3 levels deep (Schools -> Building Name -> Page Name)

If there isn't a way to fix the way the list displays, is there maybe a way to add the parent page's name to the page name? Or another way to build the menus?

Share Improve this question asked Oct 25, 2017 at 20:33 LoganGoesPlacesLoganGoesPlaces 716 bronze badges 6
  • 2 I'm pretty sure this is just a limit of pagination. If a parent and grandparent can't fit on the same page of results, the grandchildren can't really be indented to pages that aren't showing. – Jacob Peattie Commented Oct 26, 2017 at 2:48
  • I understand what you mean, but I don't think that is what is happening. None of the pages that are nested under these pages are appearing as children. All of those library listings are on the same page as their parents. – LoganGoesPlaces Commented Oct 26, 2017 at 16:11
  • It makes no difference the 'depth' of the nesting. When you are viewing the menu, it will show the nested pages if they are nested in their settings. (Like open the page and define it's parent). The really weird part is that the structures is showed at some parts. Can you specify where it's working and where it isn't? – Marcelo Henriques Cortez Commented Nov 3, 2017 at 17:44
  • There's hardly any rhyme or reason to it. Most (but not all) second level nesting displays but none of the third level nesting displays. For example, all of our school buildings are nested under "Schools" and only two of the buildings out of 8 display as such. The rest are listed as if they do not have a parent. All of the pages nested under each of the schools display as first level. To test I added a 3rd level page to a section that is displaying nestings properly and it does not display with it's parent. – LoganGoesPlaces Commented Nov 6, 2017 at 13:36
  • 1 @JacobPeattie You were actually write about the pagination. The pages that weren't nesting were all children of a page that starts with S ("Schools") so almost all of the children appeared on an earlier page. Once I realized that was the problem I found a bug report all about it that has been open for 6 years (core.trac.wordpress/ticket/18282). If you want to submit an answer I'll mark it correct and add what I ended up doing to remove pagination all together to it. – LoganGoesPlaces Commented Nov 8, 2017 at 19:32
 |  Show 1 more comment

3 Answers 3

Reset to default 0

For those who run into this in the future, the issue was due to pagination and the parent appearing on a different page than the children. Removing pagination from the View All menu fixed the nesting.

There is a ticket opened 7 years ago reporting this bug and it has yet to be resolved. In the comments user danburzo suggests adding the following filter, which corrected the issue for me.

<?php
  add_filter( 'nav_menu_meta_box_object', array( $this, 'disable_pagination_in_menu_meta_box' ) );

  function disable_pagination_in_menu_meta_box($obj) {
    $obj->_default_query = array(
      'posts_per_page' => -1
    );
    return $obj;
  }
?>

Yes this is annoying, I found that this happens only if the [Main Navigation] option is checked ,go to menus on theme customization; uncheck this and you will be fine.

The function you're looking for is wp_list_pages().

Pay particular attention to these two arguments documented on that page.

  • depth being the most relevant to your question.

    'depth' (int) Number of levels in the hierarchy of pages to include in the generated list. Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to the given n depth). Default 0.

  • There's also child_of, giving you the option to list only those that are children of a specific parent page that you have; i.e., a specific building's child pages.

    'child_of' (int) Display only the sub-pages of a single page by ID. Default 0 (all pages).


Tip: One more option is to use a combination of get_pages() and wp_list_pages() as shown by example here. Between the two, you should be able to display the hierarchy as desired.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749012630a315609.html

最新回复(0)