Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #365438

    Hi Guys,

    I’d like to present an alternative Main Menu to users who are logged in. Is there a way of doing this using functions.php (I’m running a child theme)

    website is over at http://www.onyoursoapbox.com

    I did find this on the WordPress Forum but it didnt work:

    // THIS THEME USES wp_nav_menu() IN ONE LOCATION FOR CUSTOM MENU.
    if ( function_exists( ‘register_nav_menus’ ) ) {
    $args = array(
    ‘menu’ => __( ‘Logged In Menu’ ),
    ‘visitor’ => __( ‘Visitor Menu’, )
    );
    register_nav_menus( $args );
    }

    Obviously I changed the variables to my menu names…

    Stuart

    #365446

    ok – manage to resolve this – found a post elsewhere in your forum. I added the following code to functions.php

    function my_wp_nav_menu_args( $args = '' ) {
     if( is_user_logged_in() && $args['theme_location'] == 'avia' ) {
      $args['menu'] = 'Main-Menu-logged-in';
    } else {
      $args['menu'] = 'Main-Menu-logged-out';
     }
     return $args;
     }
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' ); 
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Alternative Menu for logged in Users’ is closed to new replies.