I am trying to create a Menu that shows a maximum of 5 items. If there are more items it should wrap them into another <ul> Element to create a dropdown.
5 Items or less:
6 Items or more
I know this kind of functionality could easily be created with a walker that counts the menu items and wraps if there are more then 5 the remaing into a seperate <ul>. But I dont know how to create this walker.
The code that shows my menu at the moment is the following:
<?php wp_nav_menu( array( 'theme_location' => 'navigation', 'fallback_cb' => 'custom_menu', 'walker' =>new Custom_Walker_Nav_Menu ) ); ?>
I noticed that if the menu is not defined by the user and it uses the fallback function instead the walker has no effect. I need it to work in both cases.
Aucun commentaire:
Enregistrer un commentaire