I am writing a shortcode plugin that displays posts according to some parameters passed into the shortcode. I have the wp_query
to get the posts and now I am trying to get the markup for the posts according to the theme's template files.
In essence, get_template_part is exactly what I want... except that it directly loads the markup into the template. I want to get the markup for the content, perform a little post-processing and then return the markup for the shortcode. Essentially,
$listings = new WP_Query(...);
while ( have_posts() ) {
$markup .= get_template_part('content', $post->post_type);
}
return $markup
Except this obviously isn't the way that get_template_part
works. How do I get the markup for a post without rendering the markup into the page?