WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 added a new menu using this code:

wp_update_nav_menu_item($menu->term_id, 0, array(
            'menu-item-title' => 'Custom menu',
            'menu-item-url' => 'http://mylink.com',         
            'menu-item-db-id' => 0,
            'menu-item-object' => 'custom',
            'menu-item-parent-id' => 328,
            'menu-item-type' => 'Custom',           
            'menu-item-status' => 'publish',)

That code generates a menu the way I wanted. But the link is totally empty. What did I do wrong?

share|improve this question
up vote 1 down vote accepted

Your menu type is:

'menu-item-type' => 'Custom', 

But if we look in wp_update_nav_menu_item:

if ( 'custom' != $args['menu-item-type'] ) {

custom != Custom, so your URL gets stripped

share|improve this answer
Wow its get working . Thanks @Tom J Nowell – Ryan Babu Aug 8 '14 at 11:02

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.