Make WordPress Core

Opened 13 years ago

Last modified 5 months ago

#18271 new defect (bug)

Item hierarchy should be maintained when adding to menu

Reported by: johnonolan's profile JohnONolan Owned by:
Milestone: Future Release Priority: normal
Severity: minor Version: 3.2.1
Component: Menus Keywords: needs-patch
Focuses: ui, administration Cc:



Create a hierarchy of categories or pages and go to create a custom menu. In the meta boxes on the left hand side, the categories and pages are shown in hierarchical arrangement. Select all categories (for example) and add to menu.

Expected behaviour:

All links are added to custom menu and the hierarchy is maintained appropriately

Actual behaviour:

Hierarchy is lost and all menu items are top-level

This was originally raised by Jane in #17029 however the changeset in the ticket only applies to showing hierarchy in the meta boxes and doesn't cover maintaining hierarchy when adding to menu.

Attachments (1)

18271.diff (3.6 KB) - added by pento 10 years ago.

Download all attachments as: .zip

Change History (23)

#1 @nacin
13 years ago

Strongly agree with this.

#2 @vparker@…
13 years ago

Strongly agree with this.

#3 @DrewAPicture
12 years ago

  • Cc xoodrew@… added

#4 @SergeyBiryukov
11 years ago

#25483 was marked as a duplicate.

#5 @chipbennett
10 years ago

Yes, please.

#6 @Break5
10 years ago

Is there any patch/plugin to solve this, it's really frustrating ever since

10 years ago

#7 @pento
10 years ago

  • Focuses ui administration added
  • Keywords has-patch 2nd-opinion added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.1

18271.diff works, but I'd like a second opinion from someone more familiar with the menus code than I. In particular, is it sane to assume in wp_save_nav_menu_items() that the parent item will be saved before the child item?

#8 @celloexpressions
10 years ago

Might be worth noting that this may not make sense UX-wise in various scenarios. For the Menu Customizer project, I've also currently removed the checkboxes entirely in favor of adding directly on click of the item.

If you add a sub-item but not the parent, should it be added as a top-level item or as a child of something else? If you add a sub-item and its parent is in the menu somewhere, should the new item be added as a child of that parent, regardless of its position in the menu? If you add a parent item, should children automatically be added with it?

In terms of the horrific scaling problems menus have right now, I'd be very hesitant to add an additional field to all menu items to accomplish this (menu-item-parent-object-id), that will make #14134 worse.

I think the best option might be to try to flag something from the JS when the item is being added, to set the parent Id when it's first added, then add it to the appropriate part of the menu instead of the bottom one the ajax call comes back. But given the way that's structured right now, I'm not sure something like that would be feasible. I'd also be interested in a better/completely re-thought approach to all of this in the Menu Customizer feature-plugin, if anyone's interested in helping there.

#9 @pento
10 years ago

  • Milestone changed from 4.1 to Future Release

I don't think this ticket needs to do anything fancy with edge cases - it's a matter of, if a parent and child are added at the same time, they should be parent and child menu items, too. Anything else can be assumed to be the user wanting to do something their own way.

Regardless, #14134 is a giant rabbit hole, and clearly a blocker for this. I'll do some thinking about it. :-)

#10 @BuildMyWeb
9 years ago

i cant believe this problem has gone unresolved for so long. thank you pento for a temp fix. ive made these edits to core files and it seems to work:

obviously this will be a problem everytime we update Wordpress. i imagine there isnt yet a better solution or pento would have updated this?

9 years ago

  • Keywords needs-patch added; has-patch removed


#12 @ocean90
9 years ago

#32013 was marked as a duplicate.

This ticket was mentioned in Slack in #core by jorbin. View the logs.

9 years ago

#14 @jorbin
9 years ago

This remains blocked by #14134. It may be something that is invalidated by the menu in the customizor project, depending on the UI that takes and if the current menu screen is removed as a part of it.

#15 @DoodleDogCody
8 years ago

Any update here. As long as the regular Menu UI is staying around I feel like this is something that should definitely be added to core.

If selecting a parent item and a child item at the same time and inserting them into a menu they should retain their hierarchy.

#16 @ocean90
8 years ago

#37342 was marked as a duplicate.

This ticket was mentioned in Slack in #design by melchoyce. View the logs.

7 years ago

#18 @melchoyce
7 years ago

#17221 was marked as a duplicate.

#19 @melchoyce
7 years ago

Looks like #14134 is done? Can we resume this? :)

#20 @pento
7 years ago

  • Keywords 2nd-opinion removed

Quite probably, though I don't remember how 18271.diff worked. It also doesn't apply properly, and doesn't know anything about the work done on #14134.

What I'm saying is, it's probably better to ignore that patch and start fresh. ;-)

#21 @swissspidy
5 years ago

#46558 was marked as a duplicate.

#22 @SergeyBiryukov
5 months ago

#59081 was marked as a duplicate.

Note: See TracTickets for help on using tickets.