Created
July 26, 2012 21:58
-
-
Save mattboon/3184843 to your computer and use it in GitHub Desktop.
WordPress- Include template using shortcode
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
<? | |
// include template using WP shortcode | |
function my_shortcode_include() { | |
ob_start(); | |
// include your template e.g. /inc/random-panel.php | |
get_template_part('inc/random-panel'); | |
$output_string = ob_get_contents(); | |
ob_end_clean(); | |
return $output_string; | |
} | |
add_shortcode('panel', 'my_shortcode_include'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment