Wordpress List Menu Items without Links (as plain text without links)

余生长醉 提交于 2019-12-13 07:41:40

问题


I am looking for an option to list all menu items in a particular menu without the links. I came across wp_get_nav_menu_items(), but cant seem to be able to find the menu slug

http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items

If somebody can help me do this with menu name/menu id, I would be most grateful


回答1:


You can find the "menu slug"(menu name) on header.php or functions.php file.

Method 1: Look into header.php file

open your theme folder and find header.php file. In that file there will be a line similar to this:

<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

Here primary is your menu name.

Method 2: Look into functions.php file.

If you defined multiple menus, then you should check inside the functions.php file.

In that file you may find a line similar to this:

register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );

Here primary is your menu name.

Hope this will help you.



来源:https://stackoverflow.com/questions/11642278/wordpress-list-menu-items-without-links-as-plain-text-without-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!