How do I add class of dropdown
in a class wrap by li – <li class="dropdown">
in a wp_nav_menu function?
My static menu
<ul>
<li>
<a href="#hero">Home</a></li>
<li><a href="blog.html">Blog</a></li>
<li class="dropdown"><a href="#"><span>Drop Down</span> <i class="bi bi-chevron-down dropdown-indicator"></i></a>
<ul>
<li><a href="#">Drop Down 1</a></li>
<li class="dropdown"><a href="#"><span>Deep Drop Down</span> <i class="bi bi-chevron-down dropdown-indicator"></i></a>
<ul>
<li><a href="#">Deep Drop Down 1</a></li>
</ul>
</li>
<li><a href="#">Drop Down 2</a></li>
</ul>
</li>
</ul>
I have this dynamic nav menu function,
<?php
if ( has_nav_menu( 'main-menu' ) ) :
wp_nav_menu( array(
'theme_location' => 'main-menu',
'items_wrap' => '%3$s',
'add_li_class' => '',
'container' => ''
));
endif;
?>
How do I make my static menu dynamic with a dropdown in wordpress wp_nav_menu function?
2
Answers
You have 2 options.
You can add the custom class in the wordpress backend.
https://sevenspark.com/how-to/how-to-add-a-custom-class-to-a-wordpress-menu-item
Or you can use this custom php code in your functions.php
You can use this