April 21, 2026

Free PHP Shortcode Stripper to use for WordPress Migration with WP Export / WP Import

A PHP function for WP All Import's Function Editor that strips legacy page builder shortcodes — Avada, Visual Composer, Elementor — during import. Prevents markup bleed into new themes. Copy-paste ready, no plugin required.

If you’re migrating WordPress content from an old theme that used page builders, shortcodes from those builders will come through in your exported content as broken markup. This free PHP tool — two files, one for export and one for import — strips those shortcodes cleanly during a WP All Export / WP All Import migration, recovers what it can, and flags what needs manual review.

It supports Avada/Fusion, WPBakery/Visual Composer, Divi, Elementor, Beaver Builder, SiteOrigin, Themify, Cornerstone, MK/Jupiter, Enfold, Salient, X Theme, and Swift Builder.

What Does This PHP Shortcode Stripper Do?

The tool strips page builder shortcodes from exported WordPress post content before or after import. Rather than silently deleting content, it converts sliders to stacked HTML so slide content isn’t lost without a trace, recovers video embed URLs from builder shortcodes and outputs them as plain URLs that WordPress auto-embeds natively, resolves attachment IDs to real image URLs on the export side before those IDs become meaningless in the new database, leaves an HTML comment starting with BCC-SKIP anywhere content can’t be recovered so you can find and fix those posts after import, and leaves native WordPress shortcodes alone since they’ll still work in the new install.

Which Page Builders Does It Support?

The cleaner handles shortcodes from Avada / Fusion Builder, WPBakery / Visual Composer, Divi, Swift Builder, Beaver Builder, SiteOrigin, Themify, Cornerstone, MK / Jupiter, Enfold, Salient, and X Theme. It also strips Elementor’s rendered HTML — Elementor doesn’t use shortcodes; it embeds rendered markup with data-* attributes directly in post_content.

Why Are There Two Separate PHP Files?

bcc-export.php runs on the old site during export. This is the version that can resolve attachment IDs — when WordPress is still connected to the original database, it can convert an integer like 423 into a real URL like https://yoursite.com/wp-content/uploads/2023/04/hero-image.jpg. Run this first when you still have access to the old site.

bcc-import.php runs on the new site during import. It also works as a standalone cleaner if you no longer have access to the old site — it just can’t resolve attachment IDs and will leave a BCC-SKIP comment wherever it encounters one. The main reason this version exists is WP All Import’s Preview feature, which shows exactly what the cleaner will produce before anything touches your database. Use it every time.

Run both when you can: export version on the old site first, then the import version on the new site as your final check.

What Is the WordPress Attachment ID Problem in Migrations?

When you upload an image in WordPress, it’s stored in the database as a post with an auto-incremented ID. Page builders like Swift Builder and WPBakery reference that image in their shortcodes as an integer — image=”423″ or images=”12,34,56″.

When you export posts and import them into a new WordPress install, that ID has no meaning. The new database has its own IDs. ID 423 might be a completely different image — or might not exist at all.

The export version solves this by calling wp_get_attachment_url() while the old database is still live, converting the ID to a full URL before the content ever leaves the old site.

How Do I Set This Up in WP All Export and WP All Import?

On the export side, in WP All Export create a new export for your post type. In your field mapping, find the post_content field and click the PHP icon. Enter return bcc_clean( $post_content ); and paste the full bcc-export.php contents into the Export PHP Functions editor. Alternatively, save the file to wp-content/uploads/wpallexport/functions.php — functions there only run during export processing and won’t affect your live site.

On the import side, in WP All Import create a new import with your export file. In the post_content PHP field, enter the same one-liner: return bcc_clean( $post_content ); — then paste the full bcc-import.php contents into the Import PHP Functions editor and click Preview before running the full import.

Important: both files define the same function names. Never load both at the same time.

How Do I Find Content That Needs Manual Review After Import?

After your import, search all post content for BCC-SKIP. Every instance marks a place where the cleaner couldn’t recover content — usually because it hit an attachment ID that only the old database could resolve. The free Search Regex plugin can search across all posts at once from the WordPress admin, making it straightforward to pull up every post that needs a manual look.

What Content Can’t Be Recovered — Regardless of How the PHP Is Written?

Some content can’t be recovered by any shortcode stripper because it was never stored in post_content to begin with. Fusion/Avada sliders store all slide data in a separate fusion_slider custom post type — the [(putting this here so it doesn’t code it)fusion_slider] shortcode in your content is just a reference ID, so export and import that CPT separately. Revolution Slider, Smart Slider 3, and LayerSlider all store slide data in their own database tables. Elementor dynamic widgets like post grids and portfolio carousels render from other database tables at page load, so their stored HTML in post_content is empty scaffolding. Some Elementor setups also store layout JSON in a _elementor_data post meta field rather than post_content — if Elementor pages come through nearly empty after cleaning, that’s why, and you’d need to export that meta field separately.

How Do I Add More Page Builders or Keep Plugin Shortcodes?

To add a builder not in the list, find the $prefixes array in bcc_strip_builder_shortcodes() and add a line with the shortcode prefix and a label. Any shortcode starting with that prefix will be handled from there.

To keep plugin shortcodes intact — WooCommerce, contact forms, anything else you still need — comment out the bcc_strip_remaining_shortcodes() call in bcc_clean(). The prefix-based stripper only touches known builder prefixes and won’t affect plugin shortcodes on its own.

What Does Slider Output Look Like?

Slider content comes out as stacked HTML: a div with class bcc-slide, containing an img with the resolved URL, an h2 with the slide title, and a p with body copy. Slides missing a title or body copy just omit those elements. bcc-slide has no built-in styles — add CSS to your new theme to display them however you want, or use Search Regex after import to bulk-replace them with your new site’s slider shortcode format.

Background: Why This Tool Exists

Last year I migrated a large archive of news content going back to 2013 from a client site built on an outdated theme that had used several page builders at once. I was using WP All Export and WP All Import, expecting the usual issues — broken sliders, missing embedded video, stray symbol strings. What I wasn’t expecting was not finding a free PHP shortcode stripper I could just drop in and use. There are plugins that clean builder shortcodes from the database after import, but at that point the content is already in and you’ve lost the old site as a reference. I wanted to handle it during the export, while I still had the original data.

This became one of my first experiments using AI to write code — originally built with ChatGPT in August 2025 (with significant frustration, because AI coding was a different experience then than it is now in 2026), then cleaned up and code-reviewed in Claude more recently. I also rewrote it to be theme- and builder-agnostic rather than specific to that one client migration, since I’ve done enough of these to know the same problems come up every time.

Both files are posted below with inline comments throughout. Every section explains what it’s doing and why. The Swift Builder and Elementor sections go into more detail on how those builders store content — in my experience they’re the most difficult to clean, and understanding the structure is what makes the cleaning logic make sense.

Free PHP Shortcode Stripper for WP Export: bcc-export.php

Copy to Clipboard

Free PHP Shortcode Stripper for WP Import: bcc-import.php

Copy to Clipboard

Need This Done for You?

If you’d rather hand this off than DIY it — this is exactly the kind of work I do at CarrierSignal. I’ve been doing web development since the nineties. 

Built and tested in a real production environment. Developed in collaboration with Claude (Anthropic) through an iterative process of live debugging, page source analysis, and multiple rounds of testing. Code independently reviewed by Claude Sonnet for security and quality.

Share this article

Go to Top