I'm trying to display a list of posts by tag within a post. I've cobbled together the following code which I wanted to use in a shortcode, but I'm getting nothing displayed…
$args = array(
'tag' => 'my-tag'
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$query->get_template_part( 'entry-summary' );
}
}
get_template_part( 'nav', 'below' );
I've tried using this within the loop using a short code and after the loop to test without success. I'm sure I'm missing something obvious!
wp_reset_postdata();
afterwards