Support

Account

Home Forums General Issues Using ACF in php function as class

Helping

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?

    Thanks!

    Rick

  • the_field() always echos the value. Use get_field() instead https://www.advancedcustomfields.com/resources/get_field/

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

The topic ‘Using ACF in php function as class’ is closed to new replies.