I found this tutorial online that allows me to have a different menu for logged in and logged out users http://www.wpbeginner.com/wp-themes/how-to-show-different-menus-to-logged-in-users-in-wordpress/

it works great except one thing, it swaps out every menu I have, I just want to to change the main menu in the header, not my sidebar menus as well


You have the elements of the $args array from wp_nav_menu() available. You can use them with the wp_nav_menu_args filter. In your case you probably want to use theme_location or menu. Exemplary usage:

add_filter( 'wp_nav_menu_args', 'check_for_args_element' );
function check_for_args_element( $args ) {
  if ( $args[ 'theme_location' ] == 'main' ) {
    // code
  return $args;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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