// Remove unnecessary body classes generated by WordPress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function wpse15850_body_class( $wp_classes, $extra_classes ) { // List of the only WP generated classes allowed $whitelist = array( 'home','blog', 'archive', 'single', 'category', 'tag', 'error404', 'logged-in', 'admin-bar', 'search', 'search-results', 'single-post', 'custom-background', 'woocommerce', 'woocommerce-page', 'woocommerce-cart', 'woocommerce-account', 'woocommerce-checkout' ); // List of the only WP generated classes that are not allowed //$blacklist = array( '' ); // Filter the body classes // Whitelist result: (comment if you want to blacklist classes) $wp_classes = array_intersect( $wp_classes, $whitelist ); // Blacklist result: (uncomment if you want to blacklist classes) # $wp_classes = array_diff( $wp_classes, $blacklist ); // Add the extra classes back untouched return array_merge( $wp_classes, (array) $extra_classes ); } add_filter( 'body_class', 'wpse15850_body_class', 10, 2 ); |