Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chris-castillo-dev/94ea0460bb32786680e0a50920ae323b to your computer and use it in GitHub Desktop.
Save chris-castillo-dev/94ea0460bb32786680e0a50920ae323b to your computer and use it in GitHub Desktop.
/**
* Add Page Attrribute Terms (Taxonomy) to Body Tag
*/
function pro_page_attributes_class_to_body( $classes ){
if ( $pageTaxonomy = get_the_terms( get_the_ID(), 'page_attributes' ) ) {
foreach( $taxonomyTerm as $term ){
if(is_array($term)){
if(!empty($term['slug'])){
$termClass = 'page-attribute-' . $term['slug'];
array_push( $classes, $termClass );
}
}else{
$termClass = 'page-attribute-' . $term->slug;
array_push( $classes, $termClass );
}
}
}
return $classes;
}
add_filter( 'body_class', 'pro_page_attributes_class_to_body' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment