is_nav_menu( int|string|WP_Term $menu )

Check if the given ID is a navigation menu.


Description Description

Returns true if it is; false otherwise.


Top ↑

Parameters Parameters

$menu

(int|string|WP_Term) (Required) Menu ID, slug, name, or object of menu to check.


Top ↑

Return Return

(bool) Whether the menu exists.


Top ↑

Source Source

File: wp-includes/nav-menu.php

function is_nav_menu( $menu ) {
	if ( ! $menu ) {
		return false;
	}

	$menu_obj = wp_get_nav_menu_object( $menu );

	if (
		$menu_obj &&
		! is_wp_error( $menu_obj ) &&
		! empty( $menu_obj->taxonomy ) &&
		'nav_menu' == $menu_obj->taxonomy
	) {
		return true;
	}

	return false;
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.