Home › Forums › Front-end Issues › get_field always returns null even with content and page id set › Reply To: get_field always returns null even with content and page id set
Thanks for your reply John. You’re right, my code was a bit light on content but I added everything I could think of that was relevant. As mentioned I was using the front-page.php template, and my code was not contained within any loops or queries.
I did, however find the solution. I think it was a combination of misunderstanding on my part, and some ambiguity on the part of ACF + not having super clear documentation.
There are two things that are used in ACF that sound kind of the same, field group and field (type) group . So I created a field group with the assumption I could just then grab that by referencing the field group name, and have all the data contained therein as a variable. My other field worked fine because I had a field group called ‘gallery’, and within that a field (type) group also called ‘gallery’. So when I called get_field(‘gallery’) it was working because it was grabbing the field type group and not the parent field group itself. I could not find any documentation on accessing the field group directly, so not sure if that’s even possible, so just used this as the solution instead.
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.