Archived topic
Issue with custom menu item
3 replies · Started by stardrive on September 20, 2016
Hi Tom,
Please, custom menu item is not displaying in your secondary menu above the main menu.
I used this code:
function your_custom_menu_item ( $items, $args ) {
if (is_single() ) {
$items .= '<li>Show whatever</li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
In this case, Show whatever is my custom menu item.
Please, kindly assist
Regards,
Stardrive
Hi there,
I think using a plugin would be better in this case: https://en-ca.wordpress.org/plugins/if-menu/
Hi Tom,
Thanks for your response.
I replaced if (is_single() ) {
with
if(is_user_logged_in() && $args->theme_location == 'secondary')
and the code worked.
Sorry I should have informed you much earlier
Thank you.
No worries, glad you got it working :)