Reputation: 357
I'm trying to hide the "topbar" if user is logged in. Example: http://prntscr.com/chcwhl
My code at the moment is:
add_filter( 'wp_nav_menu_items', 'woohoo_add_auth_links', 10 , 2 );
function woohoo_add_auth_links( $items, $args )
{
if( $args->theme_location == 'topmenu' )
{
if ( is_user_logged_in() ) {
echo '<style>#topbar { display:none;}</style>';
}
elseif ( !is_user_logged_in() ) {
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
$items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';
}
}
return $items;
}
I'm sure that the topbar is <div class="topbar">
so I'm a little confused why it's not hiding...
Upvotes: 1
Views: 18053
Reputation: 3411
The #
means ID.
You can fix this by either using:
<div id="topbar">
Or:
echo '<style>.topbar { display:none;}</style>';
A #
is css for ID, and a .
is css for class.
Upvotes: 2