Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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
1  
Wow its get working . Thanks @Tom J Nowell –  Ryan Babu Aug 8 at 11:02

Your Answer

 
discard

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.