More fixes

"This block contains unexpected or invalid content"

You open a page in the WordPress editor and one or more blocks show a grey box: "This block contains unexpected or invalid content", with an Attempt Block Recovery button. The page itself usually still looks fine to visitors. What happened is that the block's saved HTML no longer matches what the block's code expects to see, so the editor refuses to guess. Nothing is lost yet. Here is how to find out why and fix it without throwing content away.

What the owner sees

example-bakery.com/wp-admin/post.php?post=12&action=edit

What the checks found


  

Why it happened (five minutes)

  1. Did a plugin or theme update just now? If the broken blocks are all one kind (a button, a gallery, a pricing table from one plugin) and it started after an update, the plugin changed the HTML its block saves and did not teach the editor to read the old version. This is the most common cause.
  2. Was the page edited as code? Hand edits in the Code editor (the three-dot menu, Code editor), HTML pasted from another site, or a find-and-replace tool run on the database can change a block's markup so it no longer matches.
  3. Who last edited it? On a multisite network, or for Author and Editor roles where unfiltered HTML is turned off, WordPress strips some attributes (inline scripts, some style or data- values) on save. The block comes back different from what it saved.
  4. Is it a different message? "Your site doesn't include support for the ... block" means the plugin that made the block is deactivated or deleted. That is not this error: reactivate the plugin instead.

Fix it, safest first

  1. Keep a copy first. Open the block's three-dot menu (or the page's Code editor) and copy the HTML into a text file. Revisions in the right sidebar also hold every saved version.
  2. Look before you recover. In the block's menu choose Resolve. It shows the current HTML next to what the block would make of it. If the two look the same apart from class names or spacing, recovery is safe.
  3. Click Attempt Block Recovery. It rebuilds the block from its current settings. Check the block, then Update. If something is missing, press Undo (Ctrl+Z) or restore the revision.
  4. If recovery drops content, convert instead. Convert to HTML keeps the exact markup as a Custom HTML block, so the page looks the same and nothing is lost. You can rebuild it as a normal block later.
  5. If one plugin's blocks broke after an update, update that plugin again (the fix is often already out), or roll it back to the last version that worked and tell its support. Recovering every block by hand fixes the pages but not the next post.
  6. If a role strips the markup, make that edit as an Administrator, or move the script or custom attribute into a plugin or the theme instead of the post.

What you see, what it means, what it needs

What you seeWhat it meansUsual fix
Same block type broken on many pages after an updateThe plugin changed its saved HTML without a fallbackUpdate or roll back the plugin; then recover
One block broken after editing in Code editorHand edit no longer matches the blockResolve, then recover or Convert to HTML
Block breaks every time an Editor saves itWordPress strips attributes for that roleSave as an Administrator, move the code out of the post
"Your site doesn't include support for the ... block"The block's plugin is off or deletedReactivate the plugin
"This block has encountered an error and cannot be previewed"The block's JavaScript crashed, not its contentSee the editor has encountered an unexpected error
Update button fails with "Updating failed"The save itself is blockedSee publishing failed

What not to do

Most cases are one plugin update or one recovery click. If dozens of pages are affected or recovery keeps losing content, that is what the box below is for. Related: editor unexpected error, publishing failed, changes not showing.