WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The context is the [caption] shortcode found in media.php which contains img_caption_shortcode

img_caption_shortcode also includes these lines:

 $output = apply_filters('img_caption_shortcode', '', $attr, $content);
 if ( $output != '' )
 return $output;

I'm trying to manipulate the output the caption shortcode and it struck me that I could filter the function or I could add_shortcode to replace it - is there any difference? and if so what would are the tradeoffs?

Many thanks in advance.

share|improve this question
up vote 2 down vote accepted

add_shortcode() may be overwritten, dependent upon at what point it is hooked, whereas you would have to remove_filter() to prevent the filter from executing. I think the way to go is to use apply_filters(), as that functionality is clearly put in place to do exactly what you're trying to do.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.