Site logo

[Resolved] Secondary menu code

Home Forums Support [Resolved] Secondary menu code

Home Forums Support Secondary menu code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2542856
    Jusung

    Hello. I am trying to make secondary menu without a plugin.
    So, I made 2 menus for login and logout.

    Idk how this can work cuz basically, I can’t set 2 secondary menu on wordpress.
    So, I guess I need one menu and have to change the menu item?

    `function my_wp_nav_menu_args( $args = ” ) {
    if( is_user_logged_in() ) {
    // Logged in menu to display
    $args[‘secondary-menu’] = 19;

    } else {
    // Non-logged-in menu to display
    $args[‘secondary-menu’] = 17;
    }
    return $args;
    }
    add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );

    #2542965
    David
    Staff
    Customer Support

    Hi there,

    what is the actual requirement ?
    Are you wanting to show a different menu for a logged in user ?

    #2543341
    Jusung

    Yes. I want to make a conditional menu for logined in user.

    loged in: logout, my account
    loged out: login, register

    to make this, I created 2 menu to switch depending on the condition.
    However, it is a secondary menu and I can’t set 2 secondary menu.
    Therefore, the code above doesn’t seem to work.

    I guess I just have to have one menu and switch only menu item?

    #2543371
    Fernando
    Customer Support

    Hi Jusung,

    Our recommendation for this would be to use a plugin called Conditional Menus: https://wordpress.org/plugins/conditional-menus/

    #2543393
    Jusung
    #2543397
    Fernando
    Customer Support

    Glad you resolved it!

    #2543399
    Jusung

    I will mark this as resolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.