Created
July 10, 2015 08:18
-
-
Save radist2s/db617c5f8ce7c8860304 to your computer and use it in GitHub Desktop.
Worpress Shortcode template include
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
add_shortcode('template', function ($templates = array()) { | |
$templates_render_result = ''; | |
foreach ($templates AS $key => $template) | |
{ | |
if (is_numeric($key) AND $template) | |
{ | |
$template = sanitize_file_name($template); | |
if ($template_path = get_template_directory() . "/parts/templates/$template.html" AND is_readable($template_path)) | |
{ | |
ob_start(); | |
load_template($template_path, false); | |
$templates_render_result = ob_get_clean(); | |
} | |
} | |
} | |
return do_shortcode($templates_render_result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment