• Resolved ooeygui

    (@ooeygui)


    Is there a way to figure out whether or not a custom menu has items in it, and if not then echo nothing?

    I’ve tried everything I can think of and all I get is blank container <div> and <ul> items.

    The walker argument of the wp_nav_menu() function will specify the output of each menu item but not the container.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ooeygui

    (@ooeygui)

    Ok so… has_nav_menu() will return true or false based on whether or not a “theme-location” for a menu actually has a menu assigned to it. That gets me partially there, I would like to then find out, if it DOES have a menu associated with it does that menu have items in it?

    Thread Starter ooeygui

    (@ooeygui)

    Got it! 🙂

    function is_active_nav_menu($location){
    
    	if(has_nav_menu($location)){
    
    		$locations = get_nav_menu_locations();
    		$menu = wp_get_nav_menu_items($locations[$location]);
    
    		if(!empty($menu)){
    			return true;
    		}
    
    	}
    
    	return false;
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Menu – is_active_menu()’ is closed to new replies.