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.
Clients need flexibility. Developers need a repeatable workflow that doesn’t have a steep learning curve. See how digital marketing agency Noiza found both with Advanced Custom Fields in our latest case study.https://t.co/BxQAy6COJt