Home › Forums › Front-end Issues › Kindly help with display question › Reply To: Kindly help with display question
I think the issue is that you’re trying to reference a variable in single-event.php ($instructor_organization) which is defined in functions.php – this is because the variable is “out of scope” (see: http://php.net/manual/en/language.variables.scope.php).
You’ll need something like this in single-event.php:
the_field('instructor_organization');
// OR
echo get_field('instructor_organization');
Both output the field value. Alternatively, you could do:
// in functions.php:
function get_instructor_org($post_id){
$org = get_field('instructor_organization', $post_id);
return $org;
}
// then in single-event.php:
// assuming you're in the Loop (i.e. $post variable is available)
echo get_instructor_org($post->ID);
Obviously the first way is easier, but the second gives you an idea of how variables can be passed to functions.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.