Skip to content

Instantly share code, notes, and snippets.

@gemmadlou
Last active October 16, 2024 00:28
Show Gist options
  • Save gemmadlou/7a0189bfae6c2c7268de12f1de822b8a to your computer and use it in GitHub Desktop.
Save gemmadlou/7a0189bfae6c2c7268de12f1de822b8a to your computer and use it in GitHub Desktop.
Removing Visual Composer & Shortcodes From Wordpress Content

Adding @k1sul1's suggestion from the comments as it's more concise than what I had before:

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.

@alelazcano
Copy link

Please, can you help me?

I'm trying deleting

<!-- wp:uagb/lottie {"block_id":"ba1f8cd1","lottieURl":"https://assets5.lottiefiles.com/packages/lf20_hd8ztfyp.json"} /-->

in all post, but block_id and url change.

@praful-kwt
Copy link

@alelazcano Please try running the following SQL query, but make sure to take a backup of the database before executing any queries:

UPDATE wp_posts SET post_content = REPLACE(post_content, SUBSTRING( post_content, LOCATE('<!-- wp:uagb/lottie ', post_content), LOCATE('/-->', post_content, LOCATE('<!-- wp:uagb/lottie ', post_content)) + 4 - LOCATE('<!-- wp:uagb/lottie ', post_content) ), '' ) WHERE post_content LIKE '%<!-- wp:uagb/lottie %/-->';

This query will remove the specific block from all posts. Let me know if you encounter any issues or need further assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment