Regenerate Page Builder media references

This WP-CLI guide is for administrators and developers upgrading content created before POM stored local Page Builder media as persistent attachment references.

The command resaves every WordPress post and page on one site. It also processes posts belonging to custom post types configured under POM Theme settings when the registered post type supports content editing. During each normal save, POM adds companion *_attachment_id shortcode attributes for local media URLs. External media URLs remain unchanged.

Before you begin

  • Create a database backup or run the command on staging first.
  • Run the command with an explicit --url on multisite.
  • Confirm that POM Theme and its bundled Page Builder are active for the target site.
  • Allow other normal save_post integrations to run while the command is active.

The command does not request a global cache purge and does not call a cache plugin directly. WordPress and active plugins can still invalidate an individual post through their normal save hooks.

Preview the scope

Count the eligible posts and pages without saving content:

wp pom regenerate-media-references --url=https://example.com --dry-run

Auto-drafts, revisions, attachments, reusable blocks, and custom post types not created through POM Theme settings are outside this command's scope. A theme-configured custom post type is included only when its registered supports contain editor. Published, scheduled, draft, private, pending, and trashed content is included.

Regenerate the references

Run the command interactively:

wp pom regenerate-media-references --url=https://example.com

For an unattended run, confirm the operation explicitly:

wp pom regenerate-media-references --url=https://example.com --yes

POM processes 100 IDs at a time by default. Large sites can select a batch size between 1 and 1,000:

wp pom regenerate-media-references --url=https://example.com --batch-size=250 --yes

The command prints the exact post-type slugs it will process. It preserves each post's existing modified dates. Its final summary reports the eligible total, successful saves, posts whose shortcode content changed, and failures.

Verify the result

  1. Confirm that the command finishes with zero failures.
  2. Edit a post or page that contains a local Page Builder image.
  3. Inspect its shortcode content and confirm that the URL parameter has a companion parameter such as get_image_attachment_id="345-medium".
  4. Open the page with Query Monitor and confirm that the corresponding local URL no longer calls attachment_url_to_postid().
  5. Check a shortcode containing an external image and confirm that its URL still renders and has no attachment reference.

Expected result: legacy local image URLs in posts, pages, and eligible POM custom post types acquire persistent attachment IDs and sizes while external URLs and existing modified dates remain unchanged.

Troubleshooting

If a post fails, the command reports its ID and the WordPress error. Resolve that error and run the command again; existing references are updated idempotently.

If a local URL remains unresolved, confirm that it belongs to the current site's uploads directory and that its attachment record still exists. Media from another multisite site is intentionally treated as external.