Home › Forums › General Issues › How to call ACF fields from my functions.php file › Reply To: How to call ACF fields from my functions.php file
I managed to solve it and my error was a very basic one.
I just had to call my field with an ID, such as:
$title = get_field('title', $post->ID);
$caption = get_field('caption', $post->ID);
adding $post->ID
in order to be able to reference the template part from anywhere, just because I was pulling this info from a post object.
For those seeking the same, these have been enlightening links:
http://www.advancedcustomfields.com/resources/how-to-get-values-from-a-media-attachment/
http://www.advancedcustomfields.com/resources/how-to-get-values-from-another-page/
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.