Is there a hook in WordPress that I can use to filter the output of a specific shortcode? Something like this:

add_filter('shortcode_output', 'my_filter_function', 2);

function my_filter_function ( $output, $shortcode ) {
    ....
}

Where $shortcode would be something like [my_schortcode] or even better, shortcode and its attributes separated into an array.

5 s
5

There is no filter that I know of that is meant to target individual shortcodes like you want.

You can filter attributes with shortcode_atts_{$shortcode} though.

You can hijack another shortcode by creating your own callback and registering it with the original shortcode slug. I think that is what you are probably going to need to do.

Proof of concept:

function my_gallery_shortcode($atts) {
  return 'howdy';
}
add_shortcode('gallery','my_gallery_shortcode');

Now try to use a gallery 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *