is_nav_menu_item

Determines whether the given ID is a nav menu item.

Description

is_nav_menu_item( (int) $menu_item_id = 0 ); 

Parameters (1)

0. $menu_item_id — Optional. (int)
The ID of the potential nav menu item.

Usage

  1. if ( !function_exists( 'is_nav_menu_item' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu.php'; 
  3.  
  4. // The ID of the potential nav menu item. 
  5. $menu_item_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_nav_menu_item($menu_item_id); 
  9.  

Defined (1)

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

/wp-includes/nav-menu.php  
  1. function is_nav_menu_item( $menu_item_id = 0 ) { 
  2. return ( ! is_wp_error( $menu_item_id ) && ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) );