Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Removing Visual Composer & Shortcodes From Wordpress Content

Original article explanation is here:










Finding shortcodes in general


Keeping some elements



Step 1

// Remove Visual Composer Stuff Except Images

Step 2

// Remove Custom Fonts

Step 3

# Change Visual Composer Images To...Actual Images

# Regex ID ONLY - Don't use - just to find IDs
$ (?<=\[vc_single_image image=")([0-9]*)(?=")

$ (\[vc_single_image image=")([0-9]*)(?=")(.*\])

# alternative
$ (\[vc_single_image(.*)image=")([0-9]*)(?=")(.*\])

# Replace with 
$ <PanelImage>$2</PanelImage>

Step 4

# Add more XML Elements 

# Find end of Content (use whatever element you like)
$ </Element>

$ </Element>\n\t\t<NewElement>\n\t\t</Panels>

** Other Helpers **

# Replace vc_video link with plain video
$ (\[vc_video link=['|"])([a-zA-Z://.?=_0-9]*)(['|"])(\])


$ $2

Why Remove Them In The First Place

When a user changes themes, it can be a pain to go through the site's content and fix any of the shortcodes. Maybe a shortcode was not required in the first place, and this can be changed with regular html - eg a button can simply be changed from:




Any styling associated with the theme will correctly be applied to the html.

Maybe it's better to keep the shortcode

For example, if a shortcode is already used site wide, it will be easier to keep the shortcode and retain the functionality.

Therefore extract the shortcode, and place it inside a plugin that can be used regardless of changes in themes at a later date.

An example would be:

[latest_post type="foo" number_of_columns="foo"]

If this is used in multiple places, simply create a plugin. Obviously, it would be better for the plugin to style it, however it's permissible for the theme to style it correctly.


Regex Helper


This comment has been minimized.

Copy link

commented Feb 12, 2018

Thanks for sharing this tutorial, I developed a free plugin named ( Shortcode Cleaner Lite ), to solve this exact problem.
Video demo:

It will Clean your WordPress content from any unused broken shortcodes, which it clean up unused, broken shortcodes from WordPress content automatically, so you can switch between themes and plugins without worrying and keep your content cleanly and fresh all the time, it is dealing with any theme (Divi, Avada..etc) shortcodes that are left when changing themes or plugins or page builders (Visual Composer, Elementor, Beaver…etc).

I hope it will be useful.


This comment has been minimized.

Copy link

commented Aug 30, 2018

Thanks @mohamdio!

Your plugin worked perfectly to clean out Visual Composer / WPBakery Page Builder code in literally a single click.

Amazing work! Saved me hours!


This comment has been minimized.

Copy link

commented Sep 6, 2018

Just found the wonderful Shortcode cleaner lite plugin! After having cleaned the shortcodes, how to clean the databbase from Visual Composer tables? Thank you


This comment has been minimized.

Copy link

commented Oct 10, 2018

@Internapse Thank you!

@kkri To clean up old/broken shortcodes within backend/database you should get the PRO version here:
which the lite version just remove old/broken shortcodes within the frontend site.


This comment has been minimized.

Copy link

commented Feb 21, 2019

@mohamdio Can your tool REPLACE the shortcode by actual HTML-Code, or just delete or code-snippets?

Say like

[vc_row][vc_column][vc_single_image image=“12345″ img_size=“full“][/vc_column][/vc_row]


<img src="imagesource" alt="imagealt" />

edit: missing [code]-Tags added


This comment has been minimized.

Copy link

commented Jun 11, 2019

I just wanted them all gone, so I ran this in the MySQL shell.

UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");

Note the double backslash. If you forget it, you'll replace all v's and c's with nothing, and the shortcodes will still be there.
This works for other shortcode as well, just replace vc.

Take a backup beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.