Skip to content

Instantly share code, notes, and snippets.

@bacoords
Last active June 27, 2016 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bacoords/5e41c62aa9b295cf9b0a9a6c12168e41 to your computer and use it in GitHub Desktop.
Save bacoords/5e41c62aa9b295cf9b0a9a6c12168e41 to your computer and use it in GitHub Desktop.
// Custom Templates Shortcode to Get Templates from the /templates Directory
// Usage: [gettemplate name="templatename"]
function prefix_templates_shortcode_function( $atts ){
$a = shortcode_atts( array(
'name' => 'none'
), $atts );
ob_start();
get_template_part('templates/' . $a['name']);
return ob_get_clean();
}
add_shortcode('gettemplate', 'prefix_templates_shortcode_function');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment