WP_REST_Menus_Controller::get_menu_locations( int $menu_id ): string[]

Returns the names of the locations assigned to the menu.


Parameters

$menu_id int Required
The menu id.

Top ↑

Return

string[] The locations assigned to the menu.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php. View all references

protected function get_menu_locations( $menu_id ) {
	$locations      = get_nav_menu_locations();
	$menu_locations = array();

	foreach ( $locations as $location => $assigned_menu_id ) {
		if ( $menu_id === $assigned_menu_id ) {
			$menu_locations[] = $location;
		}
	}

	return $menu_locations;
}


Top ↑

Changelog

Changelog
Version Description
5.9.0 Introduced.

Top ↑

User Contributed Notes

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