Cheers Joan,
Just to clarify, you have created a menu and added dynamically populated items to the menu, and you wish to limit the depth of the dynamic menu items, or limit the depth of the whole menu to 1 level?
James
Hi James!
First of all, excuse my english, I’m from spain, and it’s not my mother language.
I would like to choose the level of depth in the menu area, just as I can do it in the widget section. I would like to limit the depth to 1 level, not the menu items 🙂
Thanks!
Have a shot with this, i have not tried but in theory it should work.
Goto your themes header file or where ever you wish to display the menu:
$args = array(
'menu' => 'your-menu', // the menu name
'walker' => new JC_Submenu_Nav_Walker(array(
'hierarchical' => 1,
'menu_start' => 0, // set this to the depth you wish to start at
'menu_depth' => 5, // set this to how many levels you require
'show_parent' => 0,
'split_menu' => true
))
);
wp_nav_menu( $args );
Hi James!
Thanks for your help!. It’s not working. Is there anything I can change on the code, or using a hook?
Thanks again!
Sorry, It worked, actually!
Thanks, James!
Anything change for it too start working?
To display a certain depth of the menu you will be using the split/dynamic menu functionality. This works to display the relevant menu items relating to the current page.
Cheers
James
No, the snippet works fine just like that! 🙂
Thanks!