• My site is https://www.phikaps.net

    I am trying to make an alternate menu for logged in users but I am not sure where to add the code to do so.

    I am using the Parament Theme V1.2 by Automattic.

    I’m know some coding but I don’t know php so I am a bit lost.

    Any help would be appreciated.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter scarney92

    (@scarney92)

    This is the line of code in the functions.php that I believe controls where it finds it.
    I’m not sure what to change/add in though.

    register_nav_menu( ‘primary-menu’, __( ‘Primary’, ‘parament’ ) );

    This is a good question, haven’t heard it asked before.

    One thing you could try is an if/else logic switch to see if the current user is logged in or not. If not, show a different menu.

    Using https://codex.www.ads-software.com/Function_Reference/is_user_logged_in to check if the user is logged in or not.

    In functions.php:

    register_nav_menus( array(
     'primary-menu', __( 'Primary', 'parament' ),
     'secondary-menu', __( 'Secondary', 'parament' ),
    ) );
    

    Then, in header.php:

    <?php if ( is_user_logged_in() ) {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘primary-menu’, ‘theme_location’ => ‘primary-menu’ ) );
    } else {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘secondary-menu’, ‘theme_location’ => ‘secondary-menu’ ) );
    } ?>

    I didn’t test that, but it’s a starting point. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alternate menu for logged in users – Parament Theme V1.2’ is closed to new replies.