Through a PHP function, I think I can handle body class, but I think WordPress would have some specific way to handle it.
If Home.php
then class in the body should be wbody
else it should be bgody
.
As I said I can write PHP functions to print class based on the template, but Is there a more precise way to do this in the case of WordPress?
Through a PHP function, I think I can handle body class, but I think WordPress would have some specific way to handle it.
If Home.php
then class in the body should be wbody
else it should be bgody
.
As I said I can write PHP functions to print class based on the template, but Is there a more precise way to do this in the case of WordPress?
I'm not sure if I understand your question correctly, but...
If you want to set body classes based on current page, then you can use this code
function my_body_class( $classes ) {
if ( is_home() ) {
$classes[] = 'wbody';
} else {
$classes[] = 'gbody';
}
return $classes;
}
add_filter( 'body_class', 'my_body_class' );
Of course you can use other conditions in there and the list of Conditional Tags might come in handy to.