• I am able to create a menu with the following code, except I am not able to populate my custom menu field by doing so:

    $menuname = "flyout-menu";
    
    wp_delete_nav_menu( $menuname );
    $menu_id = wp_create_nav_menu( $menuname );
    
    wp_update_nav_menu_item($menu_id, 0, array(
    	'menu-item-title'      =>  __('Home'),
    	'menu-item-type'      => 'custom',
    	'menu-item-url'        => home_url(),
    	'menu-item-custom' => 'A house is not a HOME.',
    	'menu-item-status'   => 'publish'));

    My ‘menu-item-custom’ is my custom field btw. Yet when I print_r the menu item the [custom] spot is empty, any ideas how to make this work?

Viewing 1 replies (of 1 total)
  • Thread Starter lieutenantdan

    (@lieutenantdan)

    i figured a workaround if anyone needs it

    $menu_items   = wp_get_nav_menu_items( "flyout-menu" );
    					$descriptions = array( "A house is not a HOME.",
    										   "Our passion... and what it can do for you.",
    										   "Works that are worth a thousand words. Or more.",
    										   "The ones in the spotlight that you can't live without.",
    										   "The official place for all things us.",
    										   "Put yourself on the map - or let us do it for you.",
    										   "It's the people you can call up at 4 a.m. that really matter.");
    					$i = 0;
    					foreach( $menu_items as $item ){
    						update_post_meta( $item->ID, "_menu_item_custom", $descriptions[$i] );
    
    						$i++;
    					}
Viewing 1 replies (of 1 total)
  • The topic ‘Create menu with custom fields’ is closed to new replies.