Home › Forums › Gutenberg › Post Objects and get_field() in ACF Gutenberg Blocks › Reply To: Post Objects and get_field() in ACF Gutenberg Blocks
Thanks for the topic.
This is an interesting one, and one that I don’t yet have a solution for. Hopefully the following info can help shine some light on the problem.
To allow the ACF template functions such as
get_field() to work as expected within the block callback/template, we had to “inject” the block values into the “acf/pre_load_metadata” filter. This filter is run when ACF attempts to load a meta value for any given key/object_id.
This “injecting” behavior is overwriting/preventing your code from reading from the newly “setup postdata”.
I’ll have a think about how we can add compatibility with this function, but am not yet sure on the solution :S
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!
© 2023 Advanced Custom Fields.