I am trying to create a table containing information that is a result of two different loops. The first loops through a list of custom post types to display team names. The other is to provide data concerning each of the teams and stored as metadata. So I think I need some way of constructing a double query in order to create a single loop. This is what I have so far:
$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 } ?>