WordPress wp_get_nav_menu_items-第一个参数是什么? [英] WordPress wp_get_nav_menu_items - what is the first param for?
问题描述
据我了解,要列出所有菜单项,我们可以使用此wp_get_nav_menu_items( $menu, $args )
,并根据文档进行操作:
As far as I understand, to list all the menu items, we can use this wp_get_nav_menu_items( $menu, $args )
, and according to the doc:
要获取WordPress中的菜单项列表,可以使用该功能 wp_get_nav_menu_items(),这需要两个参数,第一个是 菜单ID,第二个是用于自定义项目的额外参数.
To get a list of menu items in WordPress you can use the function wp_get_nav_menu_items(), this takes two parameters first being the menu ID and second being extra parameters to customise the items.
但是我不明白,第一个参数的菜单ID 是什么?我需要什么?我只想列出所有菜单项!
But I don't understand, what is the menu ID about for the first param? What do I need it for? I just want to list all the menu items!
我该如何获得这个$菜单?我从哪里得到的?
And I how can I get this $menu? Where do I get it from?
推荐答案
它的确切含义是-菜单ID.但是它不必是ID,可以是name
,slug
或ID
.您可以在Appearance => Menus
下找到菜单.在此可以找到菜单名称,该名称显示了菜单名称,您可以将其作为第一个参数传递给wp_get_nav_menu_items()
.菜单下拉菜单<option>
中的value
显示每个菜单的ID
,您也可以将它们作为第一个参数传递给wp_get_nav_menu_items()
. slug
=以菜单名称作为参数传递的sanitize_title()
调用结果,也可以作为第一个参数传递wp_get_nav_menu_items()
.
It's exactly what it is - menu ID. But it doesn't have to be ID, it can be name
, slug
or ID
. You can find your menus under Appearance => Menus
. There you can find Menu Name which shows name of your menu which you can pass to wp_get_nav_menu_items()
as first parameter. value
in <option>
in the dropdown of menus shows ID
of each menu which you can also pass to wp_get_nav_menu_items()
as first parameter. slug
= result of call of sanitize_title()
with menu name passed as parameter and it can be also passed wp_get_nav_menu_items()
as first parameter.
这篇关于WordPress wp_get_nav_menu_items-第一个参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!