Get_template_part inside filter?
You can use output buffering to get the template output and return it in place of the emptied shortcode content: if ($pos !== false) ob_start; get_template_part(‘content-gallery.php’); $contentgallery = ob_get_contents(); ob_end_clean(); return substr_replace( $content, $contentgallery, $pos, strlen($shortcode[0]) );` } EDIT It might make it easier to just replace the gallery shortcode? remove_shortcode(‘gallery’); add_shortcode(‘gallery’,’my_content_gallery’); function my_content_gallery() { … Read more