WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the code below to create custom menu items on the fly. Its working great, except all menus are created as "Custom". In the code below, setting the menu-item-type to 'page' appears to have no effect.

        foreach($thePages as $page){
            wp_update_nav_menu_item($menu->term_id, 0, array(
                'menu-item-title' => $page->post_title,
                'menu-item-type' => 'page', 
                'menu-item-status' => 'publish')

wp-includes/nav-menu.php shows that the value is hard coded to "Custom". However, if I manually add a page to the menu, using the WP Menus manager, it lists it as "Page", not "Custom". What can I do to set the menu type to "Page"?

share|improve this question
I've used the filter 'nav_menu_css_class' to modify the css classes. Is this what you wanted? – Cristian Apr 21 '11 at 19:36
@Wild Phoenix: I'm creating a custom menu on the fly, then iterating over the top level pages and assigning each of them to the custom menu. This is all done via a plugin during its activation hook. Its not related to css at all at this point. I'm just trying to figure out how to get each menu registered as a "Page" and not as "Custom" in my code above. – Scott B Apr 21 '11 at 19:42
try setting menu-item-object-id in your array to the page id – Bainternet Apr 21 '11 at 19:45
@baininternet: Will do. Thanks to the help and suggestion. – Scott B Apr 28 '11 at 17:18
@bainternet: This didn't work. Still shows as "Custom". 'menu-item-object-id' => $page->ID – Scott B Apr 29 '11 at 19:00
up vote 1 down vote accepted

There's a filter:

function wpse15368_update_menu_item_type( $args )
    return $args['menu-item-type'] = 'page';
add_action( 'wp_update_nav_menu_item', 'wpse15368_update_menu_item_type' );
share|improve this answer

Strange it maybe, `post_type' is the keyword to use:

'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
'menu-item-object-id' => $post_id

This will make a menu item just like you manually created one.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.