Created
February 23, 2015 14:00
-
-
Save setola/d07f3991c3c8df6556d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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