Skip to content

Instantly share code, notes, and snippets.

@radist2s
Created July 10, 2015 08:18
Show Gist options
  • Save radist2s/db617c5f8ce7c8860304 to your computer and use it in GitHub Desktop.
Save radist2s/db617c5f8ce7c8860304 to your computer and use it in GitHub Desktop.
Worpress Shortcode template include
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