WordPress.org

Ready to get started?Download WordPress

Forums

Help switching logged in menu and logged out menu (2 posts)

  1. MeAgainAtPMP
    Member
    Posted 1 year ago #

    I have two web sites running WordPress 3.5 with Theme Twenty Eleven. I am trying to set them up the same to make it easier to manage. On both web sites I have two menus named loggedin and loggedout. I used the code below in functions.php to switch the menus based on the user being logged in or not. This works on one web site and not the other. Can anyone show me how they modified functions.php to switch menus. Then maybe I can figure this out. Thanks

    // This theme uses wp_nav_menu() in one location.
    register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
    //I ADDED THE TWO LINES BELOW. MY MENUS ARE loggedin AND loggedout
    register_nav_menu( 'primary', __( 'Logged In Menu', 'loggedin' ) );
    register_nav_menu( 'primary', __( 'Logged Out Menu', 'loggedout' ) );

  2. jibbius
    Member
    Posted 1 year ago #

    Not twentyeleven, but I do this:

    <?php
    						if ( is_user_logged_in() ) {
    							wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'loggedin', 'fallback_cb' => 'bp_dtheme_main_nav' ) );
    						} else {
    							wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav' ) );
    						};
    					?>
    				</div>
    			</div>

Topic Closed

This topic has been closed to new replies.

About this Topic