感谢mrben522为我们指明了方向;
<?
$args = array(
\'post_type\' => \'any\',
\'category__in\' => wp_get_post_categories($post->ID),
\'posts_per_page\' => 7,
\'post__not_in\' => array($post->ID) ,
);
$related = new WP_Query($args);
if( $related->have_posts() ) : ?>
<ul class="related-posts">
<?
$array = array (\'article\', \'post\', \'video\', \'webinar\', \'factsheet\',\'whitepaper\', \'casestudy\');
foreach ($array as $value) {
while( $related->have_posts() ) : $related->the_post() ;
if ($post->post_type == $value) {
get_template_part(\'template-parts/content\', \'related\');
}
endwhile;
rewind_posts();
}
?>
</ul>
<? endif;
wp_reset_postdata(); ?>