Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides
  • http://www.wpbeginner.com/ WPBeginner Staff

    Under Appearance > Menus you need to choose a location for your menu. Seems like there are two areas on your site where you can add menus. So you need to create two different menus and then assign a location to them.

  • Rob

    OMG, this made me laugh it was so simple… thank you!

  • Melih

    Illustrative and easy, thank you so much.

  • Rohit Gahlot

    Working .. :D Thanks a lot

  • Seth

    Thanks for this.

    On the homepage, menu names that have a submenu (a drop-down menu) do not show the drop-down. When I go to any other page that isn’t my homepage, this isn’t a problem, and all menu items are shown.

    This is the case on the homepage for both logged-in and logged-out items. Any idea how to fix this? Thanks

    http://www.viridianmgt.com/wordpress

    • http://www.wpbeginner.com/ WPBeginner Support

      Seems like a theme issue. Contact your theme support.

  • Wouter Bredenbeek

    Only changing a certain menu can be achieved by changing $args['menu'] = ‘logged-in’;
    into $args['secondary-menu'] = ‘logged-in’; for example. Should do the trick!

    • DANIEL

      That code doesn’t work. I have registered a ‘primary-menu’ and ‘secondary-menu’ and trying the function provided with your change in args no menú changes.

      I fix this using this code:

      function my_wp_nav_menu_args( $args = ” ) {
      if ($args['theme_location'] == ‘secondary-menu’) {
      if( is_user_logged_in()) {
      $args['menu'] = ‘logged-in’;
      }else{
      $args['menu'] = ‘logged-out’;
      }
      }else{
      $args['menu'] = ‘Principal’;
      }
      return $args;
      }

      add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );

      NOTE: ‘ Principal is the name of the primary static menu.

      • Rory PQ

        So close, both my footer and main menus are changing. I’m trying to just change my footer menu. I’ve tried so many variations of this code but no dice. Any solution thoughts?

        When I inspected my theme with Firebug it said my footer is “id=footer-nav”. Should I use this name rather than “secondary-menu”?

        Many Thanks

  • lemonthirst

    Hurray! Finally found it, it never crossed my mind that this simple function would ease up my work so much.
    Thank you guys!

  • Grant

    When I try to enter the code into the functions.php file it gives me the following error:

    Parse error: syntax error, unexpected ’03′ (T_LNUMBER) in /home/grantkessler/public_html/wp-content/themes/GameNews/functions.php on line 201

  • Stevie Allison

    Perfect just what I was looking for. i´m going to try it now. Thank You

    • Stevie Allison

      It works perfect. Thank You

  • Alex

    Big thanks for sharing code but it really add this menu in all areas! Is there a way to show it only in specific menu ?

  • shanewaj rahman

    Thanks,
    You made it so easy.

  • zaman

    I created site specific plugin and menu’s working fine, but my footer menu is also changed, its not showing the one i selected but the logged-in or logged-out.

    • http://www.wpbeginner.com/ WPBeginner Support

      Zaman WordPress menus have locations assigned to them. Make sure you are using a different menu for the footer menu location.

  • Grant

    Hi when I try to put in the code it messes up my site completely giving the error message:

    function my_wp_nav_menu_args( $args = ” ) { if( is_user_logged_in() ) { $args['menu'] = ‘logged-in’; } else { $args['menu'] = ‘logged-out’; } return $args; } add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );
    Warning: Cannot modify header information – headers already sent by (output started at /homepages/5/d156331781/htdocs/reviewthegame/wp-content/themes/Made-Theme/made/functions.php:12) in /homepages/5/d156331781/htdocs/reviewthegame/wp-includes/pluggable.php on line 899

  • joseph

    Is there a way to only apply this to a specific menu?
    I have tried this:
    if( $args->theme_location == ‘primary-menu’ ) {
    //Code here
    }
    but it doesn’t work. any ideas how to achieve this?

    • shanewaj rahman

      This is what I have done to over come two menu problem.
      I have removed that function and put this code in the header.php
      where I was calling my menu.

      false,
      ‘menu_id’ => ‘nav’,
      ‘menu’ => ‘Registered’,
      ‘items_wrap’ => ‘%3$s’)
      );
      }
      else
      {
      wp_nav_menu( array(‘container’ => false,
      ‘theme_location’ => ‘primary’,
      ‘menu_id’ => ‘nav’,
      ‘items_wrap’ => ‘%3$s’,
      ) );
      }?>

    • Fransiska

      Use

      if ($args['theme_location'] == ‘primary’)

      instead and it’ll works

  • Jamie Mannion

    Great tip, that came at a perfect time in my site development.

    Works a treat! I think I’ll extend on this to show different menus for different user_meta.

    Thanks for sharing!

  • karen

    Hi, thanks for that, most helpful. though I’m still not sure where to put the code?
    (After creating the menus, add this code in your theme’s functions.php file or a site-specific plugin) – where is the functions.php file?
    cheers

    • http://www.wpbeginner.com/ WPBeginner Support

      Go to Appearance » Editor you will see functions.php file in the list of files on your right hand. However, if you do not see a functions.php file there, then this means you are using a theme framework or a child theme. In that case you need to create a site specific plugin for your site and add this code inside that plugin. See our guide on site-specific plugin.

  • Cathy Earle

    Great tip. Looking forward to using it in an upcoming design.