WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/has nav menu

Description

Returns boolean Whether a registered nav menu location has a menu assigned(true) or not(false).

Usage

 <?php
if ( has_nav_menu$location ) ) {
     
//Do something
?> 

Parameters

$location
(string) (required) A string of menu location slug.
Default: None

Return Values

bool True if the registered location has a menu assigned, false otherwise.

Example

 <?php
if ( has_nav_menu'primary' ) ) {
     
wp_nav_menu( array( 'theme_location' => 'primary' ) );
?> 

Changelog

Source File

Related

Navigation Menu

See also index of Function Reference and index of Template Tags.