Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
function wp_get_nav_menu_object( $menu ) {
if ( ! $menu )
    return false;

$menu_obj = get_term( $menu, 'nav_menu' );

if ( ! $menu_obj )
    $menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );

if ( ! $menu_obj )
    $menu_obj = get_term_by( 'name', $menu, 'nav_menu' );

if ( ! $menu_obj )
    $menu_obj = false;

return $menu_obj;
}

I know that has_nav_menu can be used to check if a nav menu has been assigned to a theme location however not sure what the code above does as the docs for this function are limited.

I need to check if the nav menu exists and the theme location is supported by the theme.

Code Source http://queryposts.com/function/wp_get_nav_menu_object/

share|improve this question

1 Answer 1

The answer is in the source code that you posted.

The code attempts to get the menu by ID using get_term, then by slug and name using get_term_by. If nothing is found it returns false, here:

if ( ! $menu_obj )
    $menu_obj = false;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.