Skip to content

Instantly share code, notes, and snippets.

@cccamuseme
Last active August 24, 2023 18:39
Show Gist options
  • Save cccamuseme/3182537d2f69eae25080894a99cc5907 to your computer and use it in GitHub Desktop.
Save cccamuseme/3182537d2f69eae25080894a99cc5907 to your computer and use it in GitHub Desktop.
Wordpress create shortcode to get template part
add_shortcode('my-shortcode', 'my_shortcode_function');
function my_shortcode_function($atts) {
ob_start();
get_template_part('template-parts/my-shortcode');
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment