Correctly associate new menu items with a menu when using wp_update_nav_menu_item()
wp_update_nav_menu_item() must pass tax_input to wp_insert_post() when creating items otherwise the menu-item relationship isn't made. See #22189. git-svn-id: http://core.svn.wordpress.org/trunk@22399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
86d88f8b2d
commit
ae96b842f9
|
@ -347,11 +347,12 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
|||
'post_type' => 'nav_menu_item',
|
||||
);
|
||||
|
||||
if ( $menu_id && ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) )
|
||||
$post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
|
||||
|
||||
$update = 0 != $menu_item_db_id;
|
||||
|
||||
// Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms()
|
||||
if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) )
|
||||
$post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
|
||||
|
||||
// New menu item. Default is draft status
|
||||
if ( ! $update ) {
|
||||
$post['ID'] = 0;
|
||||
|
|
Loading…
Reference in New Issue