Skip to content
Advertisement

WordPress strip single shortcode from posts

I want to strip just the shortcodes in my blog posts. The only solution I found is a filter that I added to my functions.

JavaScript

It removes all shortcodes including which I need for images. How can I specify a single shortcode to exclude or include?

Advertisement

Answer

To remove only the gallery shortcode , register a callback function that returns an empty string:

JavaScript

But this will only work with the callbacks. To do it statically, you can temporarily change the global state of wordpress to fool it:

JavaScript

Usage:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement