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: 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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.