Fix Orphaned Block Notes After WordPress Import

WordPress 6.9 introduced Block Notes, a long-overdue collaboration feature that lets your team leave contextual feedback directly on blocks in the editor. Notes appear as indicators in the block toolbar and can be resolved, replied to, and edited. They’re a big deal for editorial workflows.

There’s just one problem: if you export and import content that contains Block Notes, the notes break. They’re still attached to the post, but they’re no longer linked to their blocks. The toolbar indicators vanish, and your review notes end up orphaned in the comments list.

We discovered this while programmatically generating 40 service pages with Block Notes embedded in the WXR import file, a workflow where every page needed review flags on specific blocks.

What Causes the Bug

Block Notes use two linked pieces of data. First, a "noteId" value stored in each block’s metadata attribute inside post_content. Second, a WP_Comment record with comment_type of "note" whose comment_id matches that noteId.

When the WordPress Importer processes a WXR file, it correctly reassigns comment_id values to avoid collisions with existing comments. But it does not update the corresponding "noteId" references inside post_content. The comment gets a new ID; the block still points to the old one. The link is broken.

We’ve filed this as Trac ticket #64724.

Side note: We love that they used the comments engine to build this, we’ve done similar with custom solutions.

How Block Notes Work in WXR

If you’re building WXR files that include Block Notes, whether programmatically or through export/import, here’s how the two pieces connect.

In the block markup inside post_content, the target block gets a noteId in its metadata attribute:

Then in the same <item>, a wp:comment element with comment_type of note carries the actual note text. The comment_id must match the noteId in the block:

When the importer assigns new comment_id values (say, 3252 becomes 8901), the block still references "noteId":3252. That’s the mismatch.

Then, when you look at your notes on the imported post, you’ll see “Original block deleted.

The following PHP script finds all posts with orphaned Block Notes, maps old noteId values to their new comment_id values, and updates post_content to restore the links. It’s safe to run multiple times, and if all notes are already correctly linked, it skips the post entirely.

The Script

Option A: WP-CLI

If you have shell access, this is the fastest path:

Option B: Must-Use Plugin

No SSH? Drop the file into wp-content/mu-plugins/ and visit any admin page. It tracks the highest note comment_ID after each run, so it only fires when new note comments appear (e.g. from another import) and skips cleanly on every other page load. Keep it there for future imports, or remove it after you finish.

How the Matching Works

The key insight: WordPress exports comments sorted by comment_id ascending, and the importer processes them in that same order, assigning new sequential IDs. So the nth-smallest old ID always maps to the nth-smallest new ID.

The script collects the old noteId values from post_content, sorts them numerically ascending, sorts the new comment_id values ascending, and pairs them positionally. This is important because a note on the last block of a page can have a lower comment_id than a note on the first block if it was created first. Numeric sort handles this correctly.

When You Need This

This fix applies any time Block Notes lose their block association after import. Common scenarios include migrating content between WordPress sites, importing WXR files that contain Block Notes, programmatically generating pages with embedded review notes, and restoring from a backup where comment IDs have shifted. If you see notes attached to a post in the comments panel but no indicators on blocks in the editor, this is likely the cause.

This worked perfectly for our use case. We hope it helps you, too, until they fix the bug.

(Last Updated: February 25, 2026)


This post was developed in collaboration with Claude 4.6 Opus, ChatGPT 5.2 Thinking & Gemini 3 Pro. Image generated using Midjourney 7 and Adobe Firefly via Photoshop. The final content was edited, tested, formatted, and fact-checked by Erik Lutenegger.

Read Other Technical Snippets

All Technical Snippets

[email protected]

Need help with WordPress Migrations or Block Notes?