
You open a post in the WordPress editor and a block shows the warning “This block contains unexpected or invalid content” with buttons for Attempt Block Recovery, Convert to HTML, and Keep as HTML. This Gutenberg block invalid content fix guide explains why validation fails, which button to click (and which to avoid), and how to stop it happening across your site. Updated for 2026.
What is actually going on: Gutenberg stores each block’s HTML in the database, and every time you open the editor it re-validates that saved markup against the block’s current definition. If a plugin or WordPress core update changed what HTML the block generates — and did not register a proper migration for the old format — the stored markup no longer matches, and Gutenberg flags it. Your content is still in the database; only the editor’s validation is complaining.
What Causes “Unexpected or Invalid Content”
- Plugin update changed block markup: the block now generates different HTML than the version stored in your posts — the most common cause.
- WordPress core block API changes: major releases (6.6/6.7 changed block APIs) altering core block output.
- Missing deprecation handling: a poorly maintained block plugin with no migration path for old markup.
- HTML edited outside the editor: database edits, migration tools, or filters modifying block markup directly.
- Pasted HTML mismatch: HTML pasted into blocks that re-validate against a content hash.
How to Fix Invalid Block Content: 6 Steps
Step 1: Back up, then click “Attempt Block Recovery”
Back up the post first (copy content or rely on revisions). Then click Attempt Block Recovery — Gutenberg uses the block’s registered deprecations to match your stored HTML to a known historical version and migrate it forward. This succeeds silently in most cases. Verify the content looks correct, click Update, and move on.
Step 2: If recovery fails, preserve the HTML before anything drastic
Do not click “Convert to Classic Block” blindly — it can mangle complex blocks. Instead, switch to Code Editor view (three-dot menu → Code editor), find the block’s raw HTML, and copy it to a text editor. Now your content is safe no matter what you try next: you can paste it back as a Custom HTML block or rebuild the section fresh.

Step 3: Choose “Keep as HTML” for pasted content
If the flagged block contains HTML you pasted yourself, choose Keep as HTML — it preserves your markup exactly without WordPress trying to reformat it into a different block structure. This is the safest option for embeds and custom code.
Step 4: Update the block plugin
Well-maintained block plugins register “deprecations” — migration instructions Gutenberg uses to convert old markup automatically. Update the offending plugin to its latest version; newer releases often add the missing migration path, after which Attempt Block Recovery succeeds where it previously failed.
Step 5: Rebuild stubborn blocks fresh
For blocks that will not recover (abandoned plugins, heavily customised markup), delete the broken block and re-insert a fresh one, re-entering the content from your Step 2 backup. Tedious for one block, but it guarantees valid markup going forward. For many affected posts, use WP-CLI to list candidates: wp post list --post_type=post --format=ids and inspect content programmatically.
Step 6: Fix it at the source for custom blocks
Developers: ensure your block’s save() output matches what is stored, register deprecated migrations for every markup change, and keep block.json as the source of truth for attributes. Test updates against posts containing old markup before shipping. For editor-wide issues, see our Gutenberg unexpected error guide.
How to Prevent Invalid Block Errors
Keep block plugins updated on a schedule — falling several major versions behind lengthens the deprecation chain and makes recovery unreliable. Test plugin updates on a staging site first, checking a sample of old posts in the editor before pushing to production. Avoid editing block markup directly in the database, and prefer well-maintained block plugins whose changelogs mention deprecation handling. A pre-update backup plus a quick editor spot-check with a free WordPress health tool catches these before readers ever see them.
Conclusion
“Unexpected or invalid content” is Gutenberg’s validation catching up with a markup change — back up, Attempt Block Recovery, and only then consider the HTML options. Keep block plugins current and the error stays rare. For more WordPress editor fixes explained plainly, follow the KamiWeb blog.
