
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; }
0If 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(); }
0If 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; }
0Remove 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.
Random Code Snippet Queries: Wordpress
- Remove every class and ID from the wp_nav_menu
- 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 display author avatar in Wordpress 5
- Add new class to body tag in wordpress
- Show template file name in wordpress