Is it possible to get ACF option page field values from the JS code for a custom block?
I do not use blocks, so this is just a guess and based on getting options pages and adding them to JS in a page.
There are a couple of choices.
If the script that needs values is “Enqueued” then you need to localize the script https://developer.wordpress.org/reference/functions/wp_localize_script/
If the script is output into the page then you need to output the values to JS variables on the php side.
var some_varialble_name = '<?php the_field('some_field_name', 'options'); ?>';
Or some combination of these things.
The only other choice is to have an AJAX request in your script that gets the option values.
Thank you for your suggestion.
I actually used
wp_add_inline_script() in the end.
I thought maybe there was a clever way of getting the options value via
wp.data.select() but I can’t find one.