WordPress:菜单,但不是按主题位置
我试图弄清楚如何显示已创建的菜单,但不必将菜单分配到主题位置。
据我所知,您必须将菜单分配给主题菜单位置,然后 wp_nav_menu 从您想要的任何位置调用菜单。
我不想将菜单分配给主题位置。相反,我希望能够创建一个菜单,然后在我的主题中查询它......无论主题位置如何。
我为自己创建了一个插件,它使用 wp_get_nav_menus 列出我创建的所有菜单...然后我可以将任何菜单分配给页面/帖子。现在,我再次试图弄清楚如何检索该特定菜单......而不是菜单主题位置。
有人吗?
I'm trying to figure out how to display a menu that has been created, but without having to assign the menu to a theme location.
From what I can tell, you have to assign a menu to a theme menu location and then wp_nav_menu calls a menu from whatever location you want.
I don't want to have to assign a menu to a theme location. Instead, I want to be able to create a menu and then query it within my theme... regardless of theme location.
I've created a plugin for myself that uses wp_get_nav_menus to list all of the menus I've created... I can then assign any menu to a page/post. Now, I'm stuck trying to figure out how to retrieve that specific menu... again, not menu theme location.
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将此代码粘贴到主题中要显示的任何位置
Paste this code in your theme wherever you want to display
好吧,看来我找到了我需要的东西:
http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items< /a>
我觉得奇怪的是
wp_get_nav_menus
没有记录在法典。Well, it looks like I found what I need:
http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items
I find it odd that
wp_get_nav_menus
isn't documented in the Codex.