Skip to content

Instantly share code, notes, and snippets.

@kildeby
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kildeby/6e970e75e601be9839ad to your computer and use it in GitHub Desktop.
Save kildeby/6e970e75e601be9839ad to your computer and use it in GitHub Desktop.
Hide a specific shortcake or many from the_content() in Wordpress pages
<?php if(has_shortcode(get_the_content(), 'gmedia')) : ?>
<?php
$pattern = get_shortcode_regex();
preg_match("/$pattern/s", get_the_content(), $matches);
?>
<div id="content">
<?php echo strip_shortcodes(get_the_content()); ?>
</div>
<div id="gallery">
<?php echo do_shortcode($matches[0]); ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment