Answer the question
In order to leave comments, you need to log in
How to remove extra classes from menu items in Wordpress?
Hello.
I created my own menu in wordpress
like this:
wp_nav_menu(array(
'menu' => '', // название меню
'container' => 'div', // контейнер для меню, по умолчанию 'div', в нашем случае ставим 'nav', пустая строка - нет контейнера
'container_class' => 'collapse navbar-collapse', // класс для контейнера
'container_id' => 'collapse-1', // id для контейнера
'menu_class' => 'nav navbar-nav', // класс для меню
'menu_id' => '', // id для меню
));
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-6 current_page_item menu-item-14" id="menu-item-14"><a href="http://localhost/ышеу">Главная</a></li>
Answer the question
In order to leave comments, you need to log in
Filter on nav_menu_css_class
something like:
function my_remove_all_class_item($classes, $item) {
$classes = '';
return $classes;
}
add_filter('nav_menu_css_class', 'my_remove_all_class_item', 10, 2 );
If suddenly id bothers you:add_filter('nav_menu_item_id', '__return_false');
+1 @Synoptic It's better to change the layout than to remove it from the VP
Here is a detailed description of how to remove classes and id from links - https://www.pandoge.com/haki/udalyaem-class-i-id-i...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question