Return a count of nav items

I had a scenario arise where I needed to check that a nav menu had items, so thought I’d share this simple one-liner, as the web had overcomplicated it:


And for those that aren’t keen on using functions as arguments, or accessing the object on the fly:

$nav_name = wp_get_nav_menu_name('context_navigation');
$nav_obj = wp_get_nav_menu_object($nav_name);
$count = $nav_obj->count;