I would like to create a block for Gutenberg. I currently have a default configuration:

function my_block_category($categories, $post)
    return array_merge(
                'slug' => 'my-block',
                'title' => __('BLOCK', 'my-block'),
add_filter('block_categories', 'my_block_category', 10, 2);

function gutenberg_boilerplate_block()
        plugins_url('js/gutenberg' . DIRECTORY_SEPARATOR . 'block.js'),
        array('wp-blocks', 'wp-element')

    register_block_type('myblock/shortcodes', array(
        'editor_script' => 'myblock',
add_action('init', 'gutenberg_boilerplate_block');

It works. I get my category. The goal is that I get a Dropdown Select in my category, which is filled from a JSON file.

    "text": {
        "text": "Home",
        "value": "[home]",
        "content": "0"

However, I currently have no idea how I can implement that? The shortcodes that are output are evaluated by the plugin.

Can you tell me how this can be done?

  • You want to include the json file data inside your script or inside your php? – Alvaro Jan 18 at 11:00
  • where I embed this I do not really care or I do not know the benefits of each option. I just want the values ​​to be available in a dropdown. If there is a preferable method here, I would choose this course – Tom Jan 21 at 6:17
  • But are those categories already registered in the page or do you need to register them from the Json data as well? – Alvaro Jan 21 at 12:11
  • I need to register them from the Json data. – Tom Jan 22 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.