Home › Forums › Gutenberg › ACF Blocks – Pass field value to script › Reply To: ACF Blocks – Pass field value to script
Thanks for your suggestions! I completely forgot about this issue, but I just tested this for future reference and it turns out that $post
object isn’t available yet when registering ACF Blocks using acf/init
action (as suggested in the acf_register_block_type documentation). So it’s probably better to just put the data in data-attributes in the template/render_callback and read them from there, or pass them some other way, especially if it’s just a few parameters.
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.