Hi,
I’m trying to use this filter to add a page class, but only on a parent page and its child pages. It’s not working, however, is there something wrong with my code?
add_filter( 'generate_page_class', function( $classes ) {
global $post;
if ( is_page() && $post->post_parent == '34' ) {
$classes[] = 'class_name';
}
return $classes;
} );
Note that this is not working either (adding a page class only to home page), so perhaps I’m setting up the conditional wrong in the first place):
add_filter( 'generate_page_class', function( $classes ) {
if ( is_home() ) {
$classes[] = 'class_name';
}
return $classes;
} );
Any help greatly appreciated!
Thank you so much.