How to export content without shortcodes

The shortcodes are a really great way that WordPress offers to keep content clean and easy also for not experienced users.

I really love shortcodes, but when you don’t want a certain plugin the shortcodes of that plugin become orphans.

Let’s do an example. You want to create a new website and import all the blog posts of the previous blog. But the old blog posts were edited with Divi.

Well, if you export those blog posts, you will have something that looks like this:

 

[et_pb_section fb_built=”1″ _builder_version=”4.6.3″ _module_preset=”default”][et_pb_row column_structure=”1_3,2_3″ _builder_version=”4.6.3″ _module_preset=”default”][et_pb_column type=”1_3″ _builder_version=”4.6.3″ _module_preset=”default”][et_pb_image src=”https://sample-domain/wp-content/uploads/2020/08/sample-image.png” title_text=”connect deeply rond” _builder_version=”4.8.2″ _module_preset=”default”][/et_pb_image][/et_pb_column][et_pb_column type=”2_3″ _builder_version=”4.6.3″ _module_preset=”default”][et_pb_text _builder_version=”4.6.3″ text_font=”….

 

Imagine many blog posts like that on your new website.

This problem discourages many users from using page builders that leave shortcodes after their deactivation.

You will not believe it, but the solution to this problem is given by a couple of lines of code.

Just create a functional plugin and add this code:

add_filter( 'the_content_export','ews_do_shortcode_during_export' );
function ews_do_shortcode_during_export( $content ){
    return do_shortcode( $content );
}

 

Then, go to Tools => Export and export the content, in this example the content of the blog posts.

The exported content will not have anymore the shortcodes, but the output of the shortcodes. And no matter if on the new site you will not have the same builder, the imported content will be pure HTML.

If you don’t want to create a new website, you can use the same method on the same website.

Make a full backup, export the content after adding the line of code written above, import again the same content replacing the old one.

If you need to convert the shortcodes of WPBakery, be careful, those shortcodes will not fire during the exporting process.

You will need to call the shortcodes inside the function.

In the case of WPBakery, you need this new code:

add_filter( 'the_content_export','ews_do_shortcode_during_export' );
function ews_do_shortcode_during_export( $content ){
    if( class_exists( 'WPBMap' ) ) WPBMap::addAllMappedShortcodes();
    return do_shortcode( $content );
}

 

As I know other page builders should give no problem.

Of course, this method is not only helpful for orphan shortcodes given by dismissed page builders, but for any kind of orphan shortcode.

Using this method you don’t strip the shortcodes and their content, but you replace them with pure HTML.

Of course, the plugins that give the shortcodes must be active during the exporting process.

You will find the plugin Export Without Shortcodes that converts the shortcodes to pure HTML on the official WordPress repository.