我试图创建一个包含两个不同循环结果的信息的表。第一个循环遍历自定义帖子类型列表以显示团队名称。另一个是提供关于每个团队的数据,并存储为元数据。所以我想我需要某种方法来构造一个双查询,以便创建一个循环。这就是我目前的情况:
$team = new WP_Query(array(\'post_type\' => \'team_page\') );
$args = array(
\'post_type\' => \'match_report\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'report_home-select\',
\'value\' => $team->post->ID,
\'compare\' => \'=\',
),
array(
\'key\' => \'report_away-select\',
\'value\' => $team->post->ID,
\'compare\' => \'=\'
)
)
);
$my_query = new WP_Query($args);
$played = $my_query->post_count;
if ( $team->have_posts() ) {
while ( $team->have_posts() ) {
$team->the_post();
?>
<tr>
<td class="teamname"><?php the_title(); ?></td>
<td><?php echo $played;?></td>
<td>9</td><!-- won -->
<td>0</td><!-- draw -->
<td>2</td><!-- lost -->
<td class="goalinfo"></td><!-- goals for -->
<td class="goalinfo">10</td><!-- goals against -->
<td class="goalinfo">33</td><!-- goal difference -->
<td class="total">27</td><!-- goal total -->
</tr>
<?php } ?>