W3cubDocs

/WordPress

WP_Navigation_Fallback::get_nav_menu_at_primary_location(): WP_Term|null

Gets the classic menu assigned to the primary navigation menu location if it exists.

Return

WP_Term|null The classic nav menu assigned to the primary location or null.

Source

private static function get_nav_menu_at_primary_location() {
	$locations = get_nav_menu_locations();

	if ( isset( $locations['primary'] ) ) {
		$primary_menu = wp_get_nav_menu_object( $locations['primary'] );

		if ( $primary_menu ) {
			return $primary_menu;
		}
	}

	return null;
}

Changelog

Version Description
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_navigation_fallback/get_nav_menu_at_primary_location