php 菜单获取菜单位置按位置获取项目

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 菜单获取菜单位置按位置获取项目相关的知识,希望对你有一定的参考价值。

$locations = get_registered_nav_menus();
$menus = wp_get_nav_menus();
$menu_locations = get_nav_menu_locations();

$location_id = 'riddell-shop';
if (isset($menu_locations[ $location_id ])) {
	foreach ($menus as $menu) {
		// If the ID of this menu is the ID associated with the location we're searching for
		if ($menu->term_id == $menu_locations[ $location_id ]) {
			// This is the correct menu

			// Get the items for this menu
			$menu_items = wp_get_nav_menu_items($menu);

			// Now do something with them here.
			//
			//
			break;
		}
	}
} else {
	// The location that you're trying to search doesn't exist
}

以上是关于php 菜单获取菜单位置按位置获取项目的主要内容,如果未能解决你的问题,请参考以下文章