I want to apply css on the rows in a specific page, but all the pages have the same row-classes. So I taught its better to add a specific class to the page and then apply the css on it. I use ACF and I don't know how to add class to this page. I tried different codes into function.php with no luck. Exp:
function be_portfolio_archive_body_class( $classes ) {
$classes[] = 'sortiment';
return $classes;
}
add_filter( 'body_class', 'be_portfolio_archive_body_class' );
CodePudding user response:
Set ACF Field Rule to show on page and save a field named acf_class_name
if( is_page() ){
global $post;
$id=$post->ID;
$acf_class=get_field('acf_class_name',$id);
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( $acf_class ) );
} );
}
CodePudding user response: