I’m building a membership website on WordPress and would like to show a different navigation menu to logged in users.
Here is the current PHP code that displays the menu :
<?php /* Our navigation menu. */ ?>
<?php if ( isset ($options['admired_remove_superfish']) && ($options['admired_remove_superfish']!="") )
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
else
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu_class' => 'sf-menu','fallback_cb' => 'admired_page_menu' ) );?>
Here’s the PHP code that needs to replace that code :
<?php
if ( wp_emember_is_member_logged_in() ) {
wp_nav_menu( array( 'menu' => 'logged-in-members' ) );
} else {
wp_nav_menu( array( 'menu' => 'normal-visitor-menu' ) );
}
?>
If I just replace the old code, with the newer code it will work, but the formatting is off. I need the Superfish part in the current code, but I’m not sure how to make it work in PHP.
I know this may be a little confusing, but I would appreciate any help. Thanks!
P.S. This is a tutorial from the plugin’s site. I’ve been following it, but I somehow need to keep the Superfish in there. I’m sure not sure how to do it.
The
'menu_class' => 'sf-menu'
will add thesf-menu class
for the menu(<ul class="sf-menu">)
andsuper fish
plugin will use thisclass
to identify the menu and style will be applied which has been declared in thesuper fish
plugin’scss
For more see this.
Considering the code above, the only thing that is changing is the actual location of the menu. The (existing) code is showing that you want the menu that’s in
'theme_location' => 'primary'
where, as you have a hardcoded menu you want to use, and you’re selecting it with'menu' => 'loggged-in-members'
The finished result will be…?>