Remove class from body tag in wordpress
Remove class from body tag in wordpress
In this session, we will try our hand at solving the "Remove class from body tag in wordpress".
-
Remove multiple classes from body tag in wordpress
--PATH wp-content\themes\<yourTheme>\functions.phpadd_filter('body_class', 'remove_body_classes'); function remove_body_classes( $classes ) { $remove_classes = ['custom-class', 'archive']; $classes = array_diff($classes, $remove_classes); return $classes; }
If you want to remove any particular class or classes from the body tag in wordpress you can remove it by using array_diff() function. array_diff() function removes the list of items of an array from the given array. You can pass more classes with comma separated values to $remove_classes variable. Just copy/paste code in your functions.php file to remove unwanted classes in wordpress.
-
Remove all nasty classes from body tag
--PATH wp-content\themes\<yourTheme>\functions.phpadd_filter('body_class','remove_all_class_names'); function remove_all_class_names($classes) { return array(); }
If you want to remove all classes from body tag in wordpress just add code to your theme's function.php file. It will remove all the nasty classes from your body tag.
-
Remove a single class from body tag in wordpress
--PATH wp-content\themes\<yourTheme>\functions.phpadd_filter('body_class', 'remove_body_class'); function remove_body_class( $classes ) { $remove_class = ['remove-class']; $classes = array_diff($classes, $remove_class); return $classes; }
Remove a single class from body tag in wordpress, you can use this method to remove a single class from the body in wordpress. You can change the value of $remove_class variable and pass the class name which you want to remove from the page.
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 use shop in product category and product permalink in woocommerce
- 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
- Custom post type in wordpress
- Create shortcode in wordpress functions php
- Show template file name in wordpress
- How to display author avatar in Wordpress 5
- How to hide PHP Warnings and Notices in WordPress?
- Create a accordion plugin in wordpress
- Remove every class and ID from the wp_nav_menu
- Add new class to body tag in wordpress
- Replace Live Site Url with Local Site URL in wordpress database
- Function to get the post id in while (have_posts()) : the_post();