has_nav_menu() – Determines whether a registered nav menu location has a menu assigned to it.

You appear to be a bot. Output may be restricted

Description

Determines whether a registered nav menu location has a menu assigned to it.

Usage

$bool = has_nav_menu( $location );

Parameters

$location
( string ) required – Menu location identifier.

Returns

bool Whether location has a menu.

Source

File name: wordpress/wp-includes/nav-menu.php
Lines:

1 to 19 of 19
function has_nav_menu( $location ) {
  $has_nav_menu = false;

  $registered_nav_menus = get_registered_nav_menus();
  if ( isset( $registered_nav_menus[ $location ] ) ) {
    $locations    = get_nav_menu_locations();
    $has_nav_menu = ! empty( $locations[ $location ] );
  }

  
/**
 * Filters whether a nav menu is assigned to the specified location.
 *
 * @since 4.3.0
 *
 * @param bool   $has_nav_menu Whether there is a menu assigned to a location.
 * @param string $location     Menu location.
 */
  return apply_filters( 'has_nav_menu', $has_nav_menu, $location );
}
 

 View on GitHub View on Trac