how to add class to functions.php wordpress code example
Example 1: add class to body class wordpress
add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
if ( is_page_template( 'page-example.php' ) ) {
$classes[] = 'example';
}
return $classes;
}
Example 2: woocommerce body class in childtheme
<body <?php body_class(); ?>>