Agregar nombre de categorías a las clases del Body en WordPress / Add Category Name to body_class
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
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;
}
}
// return the $classes array
return $classes;
}
Then you must go to header.php and search for the line
Ahora deber ir al archivo header.php y buscar la linea:
<body <?php body_class(); ?> itemscope itemtype=”http://schema.org/WebPage”>
Replace it for
Reemplazarla por:
<body <?php post_class(); ?> itemscope itemtype=”http://schema.org/WebPage”>