How can I add special classes ( like " japan japan_index" ) for body class in category-japan.php and for category.php something like this " archive archive_index " and also I'm using this code to put categories name on single.php and index.php body class
// Adding categories name to body class
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
// add category slug to the $classes array
$classes[] = $category->category_nicename;
}
}
else{
$classes[] = 'index';
}
// return the $classes array
return $classes;
}
// Allowed classes
add_filter( 'body_class', 'remove_some', 10, 2 );
function remove_some( $wp_classes, $extra_classes ) {
// List of the only WP generated classes allowed
$whitelist = array( 'index', 'japanese', 'japan', 'interviews', 'travel', 'reviews', 'series', 'archive' );
// Filter the body classes
$wp_classes = array_intersect( $wp_classes, $whitelist );
// Add the extra classes back untouched
return array_merge( $wp_classes, (array) $extra_classes );
}