• I’m building a member only site and I want to only have member pages navigation links in the primary nav visible after the user has logged in. Right now I have all the page links shown in the primary nav which is a problem. I’m using the Responsive Theme 1.4.9 and I see that there so some changes need to be done in the functions.php and header.php file
    I’ll list my current code in those two files below, please help with the php code snippet to replace the default theme code as you did on similar post…

    https://www.ads-software.com/support/topic/want-primary-navigation-to-change-on-members-only-pages?replies=23#post-2822856

    functions.php code looks like this

    register_nav_menus(array(
    'top-menu' => __('Top Menu', 'responsive'),
    'header-menu' => __('Header Menu', 'responsive'),
    'sub-header-menu' => __('Sub-Header Menu', 'responsive'),
    'footer-menu' => __('Footer Menu', 'responsive')
    )
    );

    header.php code looks like this

    <?php wp_nav_menu(array(
    				    'container'       => '',
    					'menu_class'      => 'top-menu',
    					'theme_location'  => 'top-menu')
    					);
    				?>
            <?php } ?>

    Please help me

Viewing 5 replies - 16 through 20 (of 20 total)
  • In Admin->Appearance->Menus, assign the ‘not logged in’ menu to the location ‘Header Menu’. Don’t assign anything to ‘Top Menu’.

    Thread Starter qmic76

    (@qmic76)

    OK, this is what I have in the admin/appearance/menu before you told me that last response..

    It says my theme supports up to 4 menus under “Theme Location”
    For top-menu I have nothing in it
    For header-menu I have nothing in it
    For sub-header I have nothing in it
    For footer-menu I have nothing in it.

    Now remember the ‘members’ menu I created is not assigned to any theme location at this point which is why all the links show up, I would play it with..I would assign ‘members’ to Header-menu under theme locations in admin/appear/menus, but then only the two links I want to show when a member is logged in shows up even on log out state, so that’s why I took ‘members’ out of header-menu and reverted back to all the links showing until I found a solution.

    The only menu I created per your request was ‘members’ from the earlier post, I did not create ‘not logged in’ menu, should I create one which would include all the not logged in links and then assign it the ‘Header-menu’? And then if that is so, where do I assign the ‘members’menu you had me make or do I leave it unassigned (not put in any of the 4 theme location menu spots)

    Create the ‘not logged in’ menu (name it ‘Not Logged In’) and assign it in the ‘Header Menu’.

    What you do with the Members menu depends on what you want to show.

    If you want the Members menu to appear in the ‘Top Menu’ location while the ‘Not Logged In’ menu appears in the ‘Header Menu’ location, put only the different things that Members should see, not everything. Assign it to the ‘Top Menu’ location. Your code will need to be changed to make this work.

    If you want the Members menu to replace the Not Logged In menu, create the Members menu and put in it everything that you want Members to see! Don’t assign it to any location. Your existing code should then work.

    Thread Starter qmic76

    (@qmic76)

    One last thing, I think the first initial code I gave you was the wrong part I showed you, I gave you the portion that related to the top-menu in header.php, when I should have gave you the portion that relates to the header-menu that is further down in the file. It looks like this..

    <?php wp_nav_menu(array(
    				'container' => '',
    				'theme_location' => 'header-menu')
    				);
    		?>

    I think I should have given you this first before you came up with a login/out snippet for me to use, and that’s why I’m having all these issues it the top-menu showing up when I don’t want one to begin with. I still will create a ‘members’ menu I know but if you get were I’m going with this, then post the ammend code snippet that you gave 3 weeks ago that will effect this code I showing now. Its just down dawned on me sorry. So i’ll need that log in/log out solution you gave me but not for the top-menu code I gave you in the initial post but for this header-menu code I’m posting now, I think that’s why its creating a top menu and all my results are showing in the top-menu area about the header menu, I’m I right…

    OK – try this:

    if ( is_user_logged_in() ) {
       wp_nav_menu(array( 'container' => '',
          'menu_class' => 'member-menu',
          'menu'  => 'Members')
          );
    } else {
       wp_nav_menu(array( 'container' => '',
          'theme_location'  => 'header-menu')
          );
    }
Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Want Primary Navigation to Change on Registered user Only Pages’ is closed to new replies.