Reputation: 763
I’m having some trouble with creating a very custom menu in WordPress.
Basically, I need to get a list of all SUB menu items for a specific menu item, for example
Menu structure
item 1 (link) <--- level 1
leftside <--- level 2
subitem a (link) <--- level 3
subitem b (link) <--- level 3
subitem c (link) <--- level 3
subitem d (link) <--- level 3
...
rightside <--- level 2
subitem a (link) <--- level 3
subitem b (link) <--- level 3
subitem c (link) <--- level 3
subitem d (link) <--- level 3
...
I want to write a function where I can ask for: 1. all the submenu items for a level 1 item and it will give me the level 2 items under it 2. all the submenu items for a level 2 item and it will give me the level 3 items under it
Upvotes: 0
Views: 613
Reputation: 468
You could determine this manually by looking at the source code output of the site. For example, menus start with tags and menu items use
For example, on one of my sites, we have an admin bar menu for BP:
<ul class="ab-sub-secondary ab-submenu" id="wp-admin-bar-my-account-wordpress">
<li id="wp-admin-bar-my-account-notifications" class="menupop">Notifications</li>
...
</ul>
In this case, the sub-items all start with the id:
wp-admin-bar-
And this particular one is wp-admin-bar-my-account-notifications.
You could for example, remove this, with something like:
function remove_nodes() {
$wp_admin_bar->remove_node('my-account-notifications');
}
add_action('admin_bar_menu','remove_nodes', 2);
Upvotes: 0