Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1138952

    I know the code below is for changing the main menu for the login user.
    Could you tell me the code for changing the secondary menu for login user?

    /*Display a different menu for registered users*/
    add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );
    function my_wp_nav_menu_args( $args = ” ) {
    if($args[‘theme_location’] === ‘avia’)
    if( is_user_logged_in() ) {
    $args[‘menu’] = ‘THE NAME OF YOUR LOGGED IN MENU HERE’;
    } else {
    $args[‘menu’] = ‘THE NAME OF YOUR LOGGED OUT MENU HERE’;
    }
    return $args;
    }

    #1139555

    Hey,

    Please use the code as following

    /*
    
    Display a different menu for registered users
    
    */
    
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
    
    function my_wp_nav_menu_args( $args = '' ) {
    
    if($args['theme_location'] === 'avia3') 
         if( is_user_logged_in() ) { 
    		$args['menu'] = 'THE NAME OF YOUR LOGGED IN MENU HERE';
              } else { 
    		$args['menu'] = 'THE NAME OF YOUR LOGGED OUT MENU HERE';
              } 
    return $args;
    }

    Best regards,
    Yigit

    #1139731

    It looks like “avia3” is not for the secondary menu
    When I change ‘avia3’ to ‘avia2’, it works.
    Thanks!

    #1139876

    Hi,

    Sorry, my bad. That is true, “avia3” is footer menu and “avia2” is secondary menu.
    Glad you figured it out though! Let us know if you have any other questions or issues :)

    Best regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to change secondary menu for login user’ is closed to new replies.