To remove only the gallery shortcode, register a callback function that returns an empty string:
add_shortcode('gallery', '__return_false');
But this will only work with callbacks. To do this statically, you can temporarily change the global state of wordpress to trick it:
function strip_shortcode($code, $content)
{
global $shortcode_tags;
$stack = $shortcode_tags;
$shortcode_tags = array($code => 1);
$content = strip_shortcodes($content);
$shortcode_tags = $stack;
return $content;
}
Using:
$content = strip_shortcode('gallery', $content);
source
share