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: https://developer.wordpress.org/reference/hooks/render_block
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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.