wordpress add class to body class 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: add class to body class wordpress
<body <?php body_class( 'class-name' ); ?>>