Hi there 👋
Unfortunately, there isn’t a built-in WP-CLI command that directly performs the same action as clicking “Attempt recovery” on blocks site-wide. That button is triggered when Gutenberg detects invalid or corrupted block markup.
That said, you can fix this in bulk without manually opening thousands of posts. Recommended solution (WP-CLI)
In most cases, simply re-saving posts via WP-CLI forces WordPress to re-parse and re-serialize the blocks, which removes the recovery notice.
⚠️ Please take a full backup first (database + files).
wp post list --post_type=any --post_status=publish --format=ids \ | xargs -n1 wp post update --post_status=publish
This command:
- Loads each post
- Reprocesses block markup
- Clears the “Attempt recovery” state
It works for posts, pages, and custom post types. If some posts still show recovery
You can force content re-serialization:
wp post list --post_type=any --format=ids \ | xargs -n1 sh -c 'wp post update "$0" --post_content="$(wp post get "$0" --field=post_content)"' Why this happens
This usually occurs after:
- Database restores
- Search/replace operations
- Editor transitions (Classic → Block)
- Plugin/theme changes that affect block markup
Hope this helps, and feel free to ask if you want to limit it to specific post types or run it in smaller batches.
Varun Sharma
Hi @cheryanne,
It sounds like you’re dealing with widespread block corruption after a restoration. This typically happens when WordPress can’t parse the block markup in your post content.
You can try a block recovery plugin, “Auto Block Recovery” or “Reusable Blocks Extended”. They can scan posts for broken blocks and attempt to recover them automatically.
Using WP-CLI, you can bulk resave posts and pages. For example:
wp post list --post_type=post,page --format=ids | xargs wp post update
This forces WordPress to re-parse the content and rebuild the block structure.
You can add --bypass if you want to skip hooks:
wp post list --post_type=post,page --format=ids | xargs wp post update --bypass
It will re-save every post and page in the database without triggering the usual WordPress processes.
But be careful, it affects every post and page and bypasses the normal safety checks!
Thank you to everyone for all your suggestions – wish me luck – backups taken.
-
This reply was modified 3 months ago by
cheryanne.