Support

Account

Home Forums Backend Issues (wp-admin) New block.json method yields "no block types exist"

Solved

New block.json method yields "no block types exist"

  • Hello all,

    I am trying to use the new block.json method of registering blocks and I’m clearly missing something. I used the TwentyTwentyTwo theme to test and when I follow the new ACF Blocks Documentation, and then try to set the Location Rule for the Block, I keep getting “No block types exist”…

    I am on WP 6.0.2 and ACF PRO 6.0.2. My code is shown below:

    twentytwentytwo/blocks/testimonial/block.json

    {
      "name": "acf/testimonial",
      "title": "Testimonial",
      "description": "A custom testimonial block",
      "style": [ "file:./testimonial.css" ],
      "category": "formatting",
      "icon": "admin-comments",
      "keywords": ["testimonial", "quote"],
      "acf": {
          "mode": "edit",
          "renderTemplate": "testimonial.php"
      },
      "align": "full"
    }

    twentytwentytwo/functions.php includes:

    add_action( 'init', 'register_acf_blocks', 5 );
    function register_acf_blocks() {
        register_block_type( get_template_directory_uri() . '/blocks/testimonial' );
    }

    I also have file twentytwentytwo/blocks/testimonial/testimonial.php but simply copy and pasted from the new docs. Still not able to find a registered block when trying to set Location Rule to Block = … Thanks in advance for anyone who is willing to help.

  • I have exactly the same problem. I am unable to register blocks using the ACF documentation for registering json blocks

  • We are also having the same issue…

  • Good afternoon mates. I contacted support and they gave me a solution that worked for me.

    I share it with you. Luck

    ——————————————————————————

    The register_block_type() expects a filesystem path(as illustrated at https://drive.google.com/file/d/1j_IaTnRnEJLFraiUKsYrdi5yEhWSkzy8/view?usp=sharing).

    That said, please try using the __DIR__ . ‘/path-to-the-block-file.json ensuring the complete path to .json file is added. For example:
    register_block_type( __DIR__ . ‘/blocks/testimonial/block.json’ );

    In other words, you can try replacing get_template_directory_uri() with __DIR__ or get_template_directory() in block registration code.

    Also, confirm if the path returned resolves to your /block.json file.

  • Thanks, all. I just heard back from support as well and the answer provided by JonasCn got it working for me.

  • In case of errors after fixing the render path – I’m using the handle-name for all scripts and styles just because the new API 2 in ACF is not fully compatible with native blocks JSON like I should expect.

    Once again – the new docs – sucks! & need to be fixed asap.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.