Support

Account

Home Forums Gutenberg Get option page fields from block (not a AFC block) Reply To: Get option page fields from block (not a AFC 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.

    
    <script>
      var some_varialble_name = '<?php the_field('some_field_name', 'options'); ?>';
    </script>
    

    Or some combination of these things.

    The only other choice is to have an AJAX request in your script that gets the option values.