我确实找到了这个问题的答案,所以我将把它留给子孙后代(因为我对自己很满意;)
$team = new WP_Query(array(\'post_type\' => \'team_page\') );
$i=0;
if ( $team->have_posts() ) {
while ( $team->have_posts() ) {
$team->the_post();
$args = array(
\'post_type\' => \'match_report\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'report_home-select\',
\'value\' => $team->posts[$i]->ID,
\'compare\' => \'=\',
),
array(
\'key\' => \'report_away-select\',
\'value\' => $team->posts[$i]->ID,
\'compare\' => \'=\'
)
)
);
$reports = new WP_Query($args);
$played = $reports->found_posts;
$i++;
?>
最大的问题是第二个查询在循环之外。我希望这对某人有帮助。