Hello! Great theme, love it so far! 🙂 I am running into an issue with the navigation menu I was hoping I could get some help on:
My website is http://www.doitforstate.com
I am trying to make the menu exactly as described in this guide: http://www.wpbeginner.com/wp-themes/how-to-show-different-menus-to-logged-in-users-in-wordpress/
I am trying to follow this article and make the user that is logged out of their account see “Sign In | Register” and users that are logged into the account show “My Account” on the main menu.
This works for me, users are seeing the correct menus when they are logged in and logged out as I would like.
One issue I ran into when doing this was the very top menu (red) displaying for a brief 2 seconds as they browse page to page. It shows a menu I do not have created. I would like, if possible, for the red banner to display (about 5px from the top), and make it seamless to navigate each page without seeing the display: none; code I have written. Here is my following code:
I tried two different things..
In header.php I created in the <head> tags:
<style>
#menu-logged-out-1, #menu-logged-in-1
{
display:none;
}
</style>
And per the article above I have tried in functions.php:
function my_wp_nav_menu_args( $args = ” ) {
if( is_user_logged_in() ) {
$args[‘menu’] = ‘logged-in’;
} else {
$args[‘menu’] = ‘logged-out’;
}
return $args;
}
add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );
I have also tried putting in header.php below the first <header> tag:
<style>
#menu-logged-out-1, #menu-logged-in-1
{
display:none!important;
}
</style>
The issue seems like it goes away once the user is cached on the site. Is there anyway to make that top red tape display about 5px from the top, and remove the very top header completely? When I turn off “Main menu” and “Top Menu” bars in the Header section in theme options, it just causes problems displaying the header completely. Any help would be greatly appreciated, thank you so much and thank for a great theme 🙂
Hi,
You added something in that area – http://screencast.com/t/2QZlHjfoq5A
The red line is actually the top menu, you could add a 5px margin-top using css.
Hiding elements using css doesn’t mean they can’t be seen, on slow computers/connections the css may be executed too slow and the user may see the menu, or some strange behavior for a few seconds before it’s hidden/adjusted.
A better alternative would be to use a plugin or something which will modify the menu for registered users.
Thank you, Emil G.
Thank you Emil I will review and let you know what I come up with 🙂