0
如何让我的菜单在数组中?WordPress - 数组中列出菜单数据?
使用wp_nav_menu ();
,我将得到HTML列表,但我不想HTML标记。我只想要数据。
我发现这个,但是这行是什么 - $menu_name = 'custom_menu_slug';
?
$menu_name = 'custom_menu_slug'; // Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)
if (($locations = get_nav_menu_locations()) && isset($locations[ $menu_name ])) {
$menu = wp_get_nav_menu_object($locations[ $menu_name ]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
}
}
任何想法?
谢谢。我见过那个文档。我不明白,也没有代码使用示例。请看看我刚刚提出的这个新问题http://stackoverflow.com/questions/35643423/wordpress-wp-get-nav-menu-items-what-is-the-first-param-for – laukok