Hi there!
I’m trying to get the value from the acf ‘kleur_switcher’ in the class of my div in a php function. The code is loading the value from ‘kleur_switcher’ but it is echo-ing it at the front-end instead of putting the value in the class.
My code:
function certificaat() {
$classCert = the_field( ‘kleur_switcher’) ;
echo “<div class'” . $classCert . “‘>Certi</div>”;
}
add_action( ‘woocommerce_after_shop_loop_item_title’, ‘certificaat’, 10 );
Can you guys help?
Thanks!
Rick
the_field()
always echos the value. Use get_field()
instead https://www.advancedcustomfields.com/resources/get_field/