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 am currently using wordpress menu like this ...

$args=array('menu'=>'menu',
            'menu_class'=>'',
            'before'=>'<span>',
            'after'=>'</span>',
            'link_before'=>'',
            'link_after'=>''
            );

      wp_nav_menu($args);

But what if want is to add a specific link to a menu item. Other than a wordpress page. Say an external link. What do i do?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You're _doing_it_wrong(). When you call wp_nav_menu(), you should be referencing theme_location, not menu.

The way the custom navigation menu functionality is intended to work:

  1. The Theme registers locations for navigation menus to appear, via register_nav_menus( array( 'location_slug' => 'Location Name' ).
  2. Then the Theme instructs WordPress where to output those menus, via wp_nav_menu( array( 'theme_location' => 'location_slug' ) ).
  3. The user defines the menu itself, via the UI at Dashboard -> Appearance -> Menus
  4. Then the user assigns a defined menu to the Theme-registered locations, via that same UI.

So, by calling menu instead of theme_location in your wp_nav_menu() call, you prevent the user from assigning a menu to that location. Very likely what's happening is that the user hasn't defined a menu with the name you're calling via the menu argument, and so WordPress is simply falling back to the default wp_page_menu() output.

Once you correct this issue, then you can define a menu with whatever links in it that you want, and then assign that menu to the appropriate location.

share|improve this answer

Adding links to a menu is done from the Admin area. You will find the menu editor under Appearance -> Menus.

Additional instructions can be found on the WordPress codex.

share|improve this answer

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.