• Hi Again,

    I’m trying to create menu items programmatically, and it seems to be working, Via an install.php file I’m able to create a new menu then add menu items. The problem is that they appear as ‘custom’ not ‘page’ and they display in the menu, but don’t work as links

    I have posted the code below. I have also created a page maually in wp, then compared the 2 menu items in the posts and postsmeta tables, and they look identical.

    Does anyone have any idea why this is happening?

    Many thanks

    John

    // add pages to the new menu
        wp_update_nav_menu_item($menu_id, 0, array(
    		'menu-item-type' => 'post-type',
    		'menu-item-object' => 'page',
    		'menu-item-author' => 1,
    		'menu-item-attr-title' => '',
    		'menu-item-status' => 'publish',
    		'menu-item-title' =>  'Home',
    		'menu-item-object-id' => 1,
    		'menu-item-name' => 7,
            //'menu-item-parent-id' => 0,
    		//'menu-item-position' => 0,
    		'menu-item-db-id' => 7,
    		//'menu-item-description' => '',
    		//'menu-item-target' => '',
    		//'menu-item-classes' => '',
    		//'menu-item-xfn' => '',
    		));

The topic ‘Programmatically create a menu item’ is closed to new replies.