Home Forums Gutenberg Dynamic blocks Reply To: Dynamic blocks

  • You don’t seem to understand what @saltnpixels is trying to achieve. The result of the render_callback specified when registering a block through ACF is stored to database on save of the post.

    The desired behaviour is to have the content generated on request. Thus the example of the latest three posts, which might be different each time a user views the post.

    The solution to the problem is using the render_block filter:

    The second argument to this hook, $block, is an array. You can compare $block['blockName'] against your block name (beware of the acf/ prefix) and return dynamic content when it matches.

    $block['attrs']['data'] is an array of all custom fields you defined for the block.