Archived topic
Page Hero query
3 replies · Started by onalti on February 26, 2022
Viewing posts 1–4 of 4
I want to add body css if Page Hero exists.
Is there a filter where I can query whether a Page Hero is or not?
Hi there,
there isn't a filter but there is a global variable you can check, see Toms reply here:
Hi there, can you give an example.
Something like this:
add_filter( 'body_class','tu_add_body_class' );
function tu_add_body_class( $classes ) {
global $generate_elements;
foreach ( $generate_elements as $element ) {
if ('header' === $element ['type'])
$classes[] = 'my-custom-body-class';
return $classes;
}
}
If the page has an header element activated, it will add a body class my-custom-body-class.
This archived topic is closed to new replies.