I am in the process of setting up a new page template that displays a page’s gallery (if it has one) in a single column, contained in an independent div, floated to the right, with all other content floated to the left. I can echo the gallery on the right via get_post_gallery(), and now I want to strip the gallery out of the_content().
What I essentially am hoping to locate is a function that does exactly the same thing as strip_shortcodes(), but for a specific shortcode. Something like strip_shortcode(‘gallery’) or strip_shortcode(‘gallery’, content()). Does anyone have such a function written up for WordPress?
remove_shortcode(‘gallery’) works bar it leaves the damn shortcode text itself behind when it runs. I can hide the gallery via CSS or remove it via jQuery but I’d rather it just not be output in the first place.
to remove a shortcode or a particular list of shortcode you can use this code.
Accepts single, comma seprated shortcode string or array of shortcodes.