is_nav_menu

Check if the given ID is a navigation menu.

Description

is_nav_menu( (int|string) $menu ); 

Returns true if it is; false otherwise.

Parameters (1)

0. $menu (int|string)
The menu to check (ID, slug, or name).

Usage

  1. if ( !function_exists( 'is_nav_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu.php'; 
  3.  
  4. // The menu to check (ID, slug, or name). 
  5. $menu = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_nav_menu($menu); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu.php  
  1. function is_nav_menu( $menu ) { 
  2. if ( ! $menu ) 
  3. return false; 
  4.  
  5. $menu_obj = wp_get_nav_menu_object( $menu ); 
  6.  
  7. if ( 
  8. $menu_obj && 
  9. ! is_wp_error( $menu_obj ) && 
  10. ! empty( $menu_obj->taxonomy ) && 
  11. 'nav_menu' == $menu_obj->taxonomy 
  12. return true; 
  13.  
  14. return false;