I've got a site in which a user can place slideshows right into a publish simply by entering the shortcode within the content box. He may add videos with the addition of the recording code within the same box. I have to separate both of these shortcodes from one another to ensure that I'm able to control once the slideshows are displayed so when the videos are displayed.

I am using add_filter and preg_match to complement the right shortcode after which echo each match out - however it's presently only exhibiting the very first match from each one of these. Here's my code - I am unsure I understand fully how add_filter works, so most likely have my display techniques wrong:


function video_slice( $content ){
    preg_match( '/\[video.*\]/' , $content , $matches );
    if( isset( $matches ) && $matches !== "" ){
        foreach( $matches as $match ){
            return $match;

if( !has_filter('the_content') ){
  add_filter( 'the_content','video_slice');   
  add_filter( 'the_content', 'video_slice');  

I've got a similar setup for that Slideshows, except my slideshow_slice function matches [SlideDeck .*] rather. How do i loop through a range of matches and print the output via the_content()?