Add Custom Body Class in WordPress

Add custom body class to specific templates.

See – https://www.billerickson.net/wordpress-class-body-tag/

<?php
/**
 * Portfolio Archive Body Class
 * @author Bill Erickson
 * @link http://www.billerickson.net/wordpress-class-body-tag/
 * 
 * @param array $classes, existing body classes
 * @return array $classes
 */
function be_portfolio_archive_body_class( $classes ) {
  
  $classes[] = 'portfolio-archive';
  return $classes;
}
add_filter( 'body_class', 'be_portfolio_archive_body_class' );