Welcome, (Visitor/User) on Top Bar Menu only
-
How can I make the Welcome, Visitor/User to appear only on the top bar menu?
function top_menu_item($items)
{
if(is_user_logged_in())
{
$user=wp_get_current_user();
$name=$user->display_name; // or user_login , user_firstname, user_lastname
return ‘- Welcome, ‘.$name.’
- Welcome, Visitor
‘ . $items;
}
else
{
return ‘‘ . $items;
}
//return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘top_menu_item’);With the function above, the Welcome Visitor/User appears on all navigation menus, top bar menu, primary menu, footer bar menu and other navigation menu I add on widgets. I want it to appear only on top bar menu.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Welcome, (Visitor/User) on Top Bar Menu only’ is closed to new replies.