Tagged: 

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

    I have created this simple function to show a different menu when not logged in:

    // set correct menu
    function display_correct_menu($args = '') {
         if ( !is_user_logged_in() ) {$args['menu'] = 'top-not-logged-in';} else {$args['menu'] = 'top';}
           return $args;
    }
    
    add_filter( 'wp_nav_menu_args', 'display_correct_menu' );

    Unfortunately, the dropdown for WPML language choice disappears when using this. Perhaps there is a better way. Perhaps you can provide a solution.

    Thanks!

    #737322

    I created a ticket with WPML support. I welcome your ideas if you have any, but this is probably something they need to look at. Thanks so much for the help!

    #737487

    This was solved by WPML support. Here it is:

    // set correct menu
    function display_correct_menu($args = '') {
           if ( !is_user_logged_in() ) { $args['menu'] = wp_get_nav_menu_object( 'top-not-logged-in' ); }
         else { $args['menu'] = wp_get_nav_menu_object( 'top' ); }
             return $args;
    }
    
    add_filter( 'wp_nav_menu_args', 'display_correct_menu' );
    
    #737492

    Hey!

    Glad they could help and thanks for sharing the solution :)

    Cheers!
    Yigit

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