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