Open
Description
$ wp menu item add …
takes the --position
argument literally and inserts it into the database exactly as specified. This is a problem when you are trying to insert one menu item between two others.
For example, on a site that already has a handful of menu links (one of which is in position 3), let's add an item like so:
$ wp menu item add-post example-menu 123 --position=3
In the wp_posts
table, the two menu links will have the same menu_order
value. This creates mixed results on the frontend of WordPress.
Now, if I go to the menu manager in WordPress and click Save Menu, WordPress recalculates and updates the duplicate menu_order
values.
Can WP-CLI do what WordPress is doing here?
Activity
ddarbyson commentedon Dec 14, 2018
Yup, I experience this too... After using
--position
option, my db results also show duplicatedmenu_order
values.wp_posts table:
ddarbyson commentedon Dec 14, 2018
Here's a screenshot to show
wp_posts
table when filtering bynav_menu_item
petruchek commentedon Nov 5, 2019
Hi there @schlessera
I'm new to github (and your project). Can I ask you to review this commit: petruchek@0311008
My questions are:
N.B. I'm also changing menu orders when delete command is called.
Here's the branch: https://github.com/petruchek/entity-command/tree/wp-cli-issue-5047
since I'm adding to it
petruchek commentedon Nov 28, 2019
Hi there, please have a look at the following PR:
#275 and let me know what's missing.