I am trying to add a body class based on an ACF block value.
My hero block has different layout choices. This is using the button_group field. The choices for the admin are:
I would like to output the value of these choices as a body class. It would also be ideal to have the script inside the block php (hero.php). I’ve tried the following but I cannot seem to get it to output.
The reason that this works in functions.php and does not work in the bock.php file is that the WP hook body_class runs before the template file is loaded. The filter must be added before the hook is run.