Archived topic
featured-image-active class still included in body when it shouldn't
22 replies · Started by George on November 8, 2020
You could try this:
add_filter( 'body_class', function( $classes ) {
if ( is_singular() ) {
$disable_featured_image = get_post_meta( get_the_ID(), '_generate-disable-post-image', true );
if ( $disable_featured_image ) {
$classes = array_diff( $classes, array( 'featured-image-active' ) );
}
}
if ( function_exists( 'generate_blog_get_defaults' ) ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_single() && ! $settings['single_post_image'] ) {
$classes = array_diff( $classes, array( 'featured-image-active' ) );
}
if ( is_page() && ! $settings['page_post_image'] ) {
$classes = array_diff( $classes, array( 'featured-image-active' ) );
}
}
return $classes;
}, 20);
Works great, Tom, thank you!
You're welcome :)
Hi!
Since GP 3.1 my child theme is broken because there's no featured-image-active class in body tag.
How to get use of it again?
I've added this little snippet to my functions.php, but I still wonder if it was intentional to get rid of the class since GP 3.1?
Moreover, seems that featured-image-active class is reserved, so I had to use other name (e.g. has-featured-image), and rewrite my CSS.
Can you open a new topic for your question?
Thanks.
Of course, here it is.
Thank you!