At the time of writing, there is still no documented way to update blocks. So here is how I would update all my blocks:
- Loop trough all posts.
- Find patterns matching:
<!-- your-block -->*<!-- /your-block -->
- Optional: convert the block to PHP Array with
parse_blocks()
- Replace according to your new block
- Save post with the updated block
Obviously, step 4 is going to be the hardest part. What you will actually do here depends on how your new block looks.
Plugin: Bulk Update Blocks
I have started work on a plugin to update blocks. https://github.com/pwkip/bulk-update-blocks
Is there no standard way to do this?
For some time now, the Gutenberg core team seems unwilling to standardize this, while there is an obvious need for this functionality as you can see here.
I hope that by the time you read this, this post will have become obsolete because there is actually a better solution at that point. If you found a better way, please leave a comment.