Wordpress List Menu Items without Links (as plain

2019-08-16 16:43发布

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条回答
对你真心纯属浪费
2楼-- · 2019-08-16 16:56

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.

查看更多
登录 后发表回答