Filter in shortcodes for the_content() – WordPress

How to filter one or more shortcodees out /in of the_content() in wordpress.

In this example I want to filter, so that only “gmedia”, a slideshow plugin that I use, will be displayed.

<?php if(has_shortcode(get_the_content(), 'gmedia')) : // Specify the shortcode to filter ?>
$pattern = get_shortcode_regex();
preg_match("/$pattern/s", get_the_content(), $matches);

<div id="content">
<?php echo strip_shortcodes(get_the_content()); ?>
<div id="gallery">
<?php echo do_shortcode($matches[0]); //This is match [0] - you can use as many as you want. ?>
<?php endif; ?>

<?php // Show the content also if the shortcake exists, but hide the shortcode
if(!has_shortcode(get_the_content(), 'gmedia')) : // Specify the shortcode to filter ?>
<?php echo strip_shortcodes(get_the_content()); ?>
<?php endif; ?>

This could be used in eg. single.php in your theme.