Can’t assign the value of the_field() to a variable

I’m using Advanced Custom Fields in WordPress. I have a file path in a field (say “submenu/abc.php” in field “ACFfield”). I want to include that info on a webpage.

If I do:

Read More
<?php include "submenu/abc.php" ?>

This works fine. But I need to do something like:

<?php 

    $file = the_field(ACFfield);
    include($file);

?>

This, however just prints out “submenu/abc.php”, from the first line (which I wouldn’t want visible anyway).

What am I doing wrong?

Related posts

1 comment

Comments are closed.