How to add bubble count in WordPress wp_nav_menu menu?

For flexibility, you could assign the CSS bubblecount class to the corresponding menu item:

enter image description here

and then target it with:

if( in_array( 'bubblecount', (array) $item->classes ) )
    $output .= '<span class="unread">'.my_function_here().'</span>';

in your code snippet above.

Leave a Comment