Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.