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:
<?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?
the_field(ACFfield);
doesn’t return anything. It just prints the filename out. Useget_field()
instead, which will return the value.