Support

Account

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.