问题
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?
回答1:
the_field(ACFfield); doesn't return anything. It just prints the filename out. Use get_field() instead, which will return the value.
来源:https://stackoverflow.com/questions/32329943/cant-assign-the-value-of-the-field-to-a-variable