Home › Forums › General Issues › get_field not returning values › Reply To: get_field not returning values
I’m 99% sure your issue is that you attempt to get the value outside of it’s context. That means that you might be trying to fetch it outside of the loop. Or from a term/user/object that’s not a post object and thus need the second parameter.
Just throwing in $post_id
won’t help you. what @imaginedd is trying to say here is that you probably need to specify this second parameter and if it’s a field belonging to a post object you have to find the posts ID and pass it as the second parameter. For example, if you’re working outside the loop and not in a single.php or page.php you might get away with:
global $post;
if( get_field('enable_box', $post->ID) ){
//Table with other ACF field values
}
We can’t help you further without more information about your setup tho so get those images working 🙂
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.