I stumbled upon a nice little way to clean up short codes in WordPress. I did not create the gist nor do I take credit for it.
MAKE A BACKUP
I cannot tell you how many times I’ve done something small directly to the database only to find that I’ve fucked EVERYTHING up.
Do not be that guy. Do not lose all your work. It is WAY easier to setup automatic backups or run manual back ups. Protect yourself, wear a condom and back up your database.
If you WP-CLI, SSH into your server and run
wp db backup.
Remove Visual Composer Shortcodes (WPBakery)
Run the following SQL query in Cpanel.
UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");
Replace “vs” with whatever short code you wish to remove. This will completely remove all
I needed this snippet because I wanted to transition away from Visual Composer (formerly WPBakery).
Remove Any WordPress Short code
I use the Woodmart theme and noticed alot of left over woodmart* shortcodes. Like I mentioned above, use the sql statement and replace ‘vc’ with whatever shortcode you wish to REMOVE.
In my case, to remove all [woodmart*] shortcodes. I ran the follow sql query.
UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?woodmart(.*?)\]", "");
Cleanup WordPress Shortcodes w/ WP-CLI
This method is easier if you have WP-CLI setup on your server AND feel comfortable executing commands. I really do not recommend you do this on a live website.
I would suggest you use VVV to setup a proper development environment.
wp search-replace --regex --verbose "\\[\/?vc(.*?)\]" "" wp_posts
Okay, check your content. If you dont see broken shortcodes anywhere you are good. Otherwise, look at remove any shortcode with WordPress .