Skip to content

Instantly share code, notes, and snippets.

@setola
Created February 23, 2015 14:00
Show Gist options
  • Save setola/d07f3991c3c8df6556d8 to your computer and use it in GitHub Desktop.
Save setola/d07f3991c3c8df6556d8 to your computer and use it in GitHub Desktop.
<?php
// First we remove all the shortcodes from the post body
add_action('the_content', 'strip_shortcodes');
get_template_part('header');
?>
<div id="main-container" class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php get_template_part('content'); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php
// Now we take only the shortcodes from the post body and print their output here, in a separate DOM element
global $post;
$pattern = get_shortcode_regex();
preg_match_all('/'.$pattern.'/s', $post->post_content, $matches);
if(is_array($matches[0])){
foreach($matches[0] as $shortcode){
echo do_shortcode($shortcode);
}
}
?>
</div>
</div>
</div>
<?php get_template_part('footer'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment