Last Updated on June 27, 2022
If you have a lot of Block Errors in Gutenberg, here’s a better way of recovering all your broken blocks in a single swoop.
In Gutenberg, when you have a broken block, the way to fix it is to click the button that says “Attempt Block Recovery”.
Easy. Problem solved.
But how about when you encounter 10 broken blocks, or maybe 50 or 100 broken blocks? Clicking on every single “Attempt Block Recovery” button would be quite tedious.
Unfortunately, broken blocks sometimes happens since Gutenberg is still evolving rapidly and Gutenberg plugins (like ours) rapidly evolve with it.
Our solution will help you recover all blocks in a single command!
How to recover all broken blocks easily in Gutenberg
The way to recover all broken blocks at once involves pasting some code into your browser’s developer console. If you find it intimidating, don’t worry, we’ll guide you.
Here’s how to recover all broken blocks at once:
- While logged into your WordPress site, edit the post that has the broken blocks.
- Press CTRL + SHIFT + J on Windows or CMD + OPTION + J on Mac to open your browser’s developer console
- Copy and paste the entire code below into your developer console then press ENTER:
After running the code above (it may take a second or two for the recoveries to work), all your blocks should be recovered. It’s as if you clicked every single “Attempt Block Recovery” button. You’ll find that even broken blocks inside reusable blocks will be fixed too.
The code doesn’t save your page, so if all looks well, be sure to update your post.
The code above is quite long, and we left it readable here to be transparent and so that you’ll know that the code above will not do anything funny when you execute it.
If you’re wondering, the code above comes from Stackable’s automatic block recovery code.
Leave a comment down below if the code worked!