Home Forums General Issues Using ACF in php function as class


Using ACF in php function as class

  • 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?



  • the_field() always echos the value. Use get_field() instead

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.