
Remove every class and ID from the wp_nav_menu
Remove every class and ID from the wp_nav_menu
With this article, we will examine several different instances of how to solve the "Remove every class and ID from the wp_nav_menu".
-
Remove class and Id attribute from list item in wordpress menu
--PATH wp-content\themes\<yourTheme>\functions.phpadd_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); function my_css_attributes_filter($var) { return is_array($var) ? array_intersect($var, array('current-menu-item')) : ''; }
Using this code snippet you can remove every class and ID attribute from the list of wordpress menu. You can remove all class and ID attribute with their values from <li> list item in menu list. It will show only the passed value to the current menu item. wp_nav_menu() function displays a navigation menu which allows you to navigate to most parts of your website.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Wordpress
- How to hide PHP Warnings and Notices in WordPress?
- Show template file name in wordpress
- Create shortcode in wordpress functions php
- Custom post type in wordpress
- Remove class from body tag in wordpress
- Function to get the post id in while (have_posts()) : the_post();
- Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/xxx/public_html/wp-includes/plugin.php on line xxx
- How to use shop in product category and product permalink in woocommerce
- How to display author avatar in Wordpress 5
- Replace Live Site Url with Local Site URL in wordpress database
- Add new class to body tag in wordpress