Reputation: 488
I would appreciate if you help me, the problem is that I have a menu and it has a submenu, and this submenu has a class by default - sub-menu, how can I change this class to submenu and how can I add to my first li - tag -
HTML:
<ul class="cf">
<li class="sub-menu"><a href="about.html">managers<i class="fa fa-angle-down fa-1g" aria-hidden="true"></i></a>
<ul class="submenu">
<li><a href="managers.html">page one</a></li>
<li><a href="shareholder.html">page two/a></li>
</ul>
</li>
</ul>
PHP:
<?php wp_nav_menu(array('theme_location'=>'menu', 'container'=>'false', 'menu_class'=>'cf', 'depth' => 2)); ?>
Upvotes: 0
Views: 1854
Reputation: 3658
Try this code :
$(document).ready(function () {
$('ul.cf').find(".sub-menu").addClass("submenu").removeClass("sub-menu");
});
May be this will work for wordpress. Write this in your theme function.php
function change_submenu_class($menu) {
$menu = preg_replace('/ class="sub-menu"/','/ class="submenu" /',$menu);
return $menu;
}
add_filter('wp_nav_menu','change_submenu_class');
Upvotes: 1
Reputation: 335
I don't know exaclty what you are trying to do. But you can find the submenu output in the file "wp-includes\class-walker-nav-menu.php".
The menu is build dynamically on the sub-menu class. So i don't know if the menu generator is still working if you change this class. Maybe it is better to add an additional class.
Upvotes: 1