Opened 11 years ago
Last modified 4 years ago
#25122 reopened enhancement
First nav menu automatically adds all pages (including sub pages) but doesn't preserve page hierarchy
Reported by: | jamescollins | Owned by: | nacin |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6 |
Component: | Menus | Keywords: | needs-patch needs-testing |
Focuses: | Cc: |
Description
When you first visit /wp-admin/nav-menus.php
in WordPress 3.6, if you don't already have a menu defined it automatically creates a new menu with all published pages in the menu.
On sites with many published pages and particularly sites with multiple levels of pages (child/parent pages), all of those pages are added as top level nav menu items.
(After the first menu is created, subsequent new menu requests create empty menus with no menu items in them).
The functionality was introduced in [23441].
Previous versions (such as 3.5) didn't automatically create a new menu.
Instead, when the first nav menu is automatically created I think we should either:
- only add all top level pages by default, or
- add all pages (including sub pages) but preserve the page hierarchy into the nav menu.
My preference would be option 1.
Attachments (4)
Change History (23)
#6
@
11 years ago
25122.2.diff
now uses a slightly less fragile selector:
#pagechecklist > li > label > input[type="checkbox"]
The child selector seems to be the easiest way to only select the top level pages, however I'm open to suggestions if anyone can think of a better way of achieving the same thing.
#8
@
11 years ago
Replying to jamescollins:
#pagechecklist > li > label > input[type="checkbox"]
Yep, this will work.
25122.3.diff is another approach that's perhaps slightly less fragile.
#9
@
11 years ago
In 25122.3.diff, parents()
can probably be replaced with closest()
, since it turns out to be faster (per the IRC discussion for #25112).
#11
@
11 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 25622:
#14
@
11 years ago
- Keywords needs-patch added; has-patch commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
This needs a new patch.
#15
follow-up:
↓ 16
@
11 years ago
Hey @ocean90,
Can you provide some additional context behind the revert? What about this patch didn't work?
25122.diff
implements suggestion 1 - only top level published pages are automatically added when creating the first nav menu.