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.
function remove_gallery($content) {
if ( is_single() ) {
$content = strip_shortcodes( $content );
}
return $content;
}
add_filter('the_content', 'remove_gallery');
It removes all shortcodes including which I need for images. How can I specify a single shortcode to exclude or include?
To remove only the gallery shortcode , register a callback function that returns an empty string:
But this will only work with the callbacks. To do it statically, you can temporarily change the global state of wordpress to fool it:
Usage:
For me, worked with:
If i try to strip_shortcode, they are remove all shortocodes and changing the final result
If you want to get only the content, excluding any shortcodes, try something like that