多亏@Bash让我开始学习,我想出了一个不错的解决方案,目前为止效果很好。
这是代码。。。
// create array of current taxonomy term slugs
$current_project_term_slugs = wp_get_object_terms($post->ID, \'project_type\', array(\'fields\' => \'slugs\'));
// convert array to comma seperated values in string to query posts with same taxonomy terms
$term_slugs = join(\', \', $current_project_term_slugs);
// set up query args
$project_query = array(
\'posts_per_page\' => 3,
\'post_type\' => \'projects\',
\'project_type\' => $term_slugs,
\'post__not_in\' => array($post->ID)
);
query_posts ( $project_query ); while ( have_posts() ) :
// next project primary
the_post();
the_title();
the_excerpt();
// next project secondary 1
the_post();
the_title();
// next project secondary 2
the_post();
the_title();
endwhile;