I came up with a way using two post queries. The first one runs through the loop and adds 1 to a variable called $counttest. Then it echos that value and resets it to 0 to begin the count for the next date.
This probably isn’t the most efficient way to do things. If anyone knows a better way then please let me know.
<?php
$today = date("Y-m-d");
$todaytext = date("l");
for ($i=0; $i<7; $i++){
$thedate = strtotime ( '+'.$i.' day' , strtotime ( $today ) ) ;
$thedate = date ( 'Y-m-d' , $thedate );
$thedatetext = strtotime ( '+'.$i.' day' , strtotime ( $todaytext ) ) ;
$thedatetext = date ( 'l' , $thedatetext );
$args = array(
'post_type' => 'event',
'orderby' => 'meta_value',
'order' => 'asc',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'opening_time',
'value' => $thedate,
'compare' => 'LIKE',
'type' => 'DATE'
),
array(
'key' => 'artist_talk_time',
'value' => $thedate,
'compare' => 'LIKE',
'type' => 'DATE'
)
)
);
$event_query = new WP_Query( $args );
if ($event_query->have_posts()) : while ($event_query->have_posts()) : $event_query->the_post();
if (get_post_meta($post->ID,'opening_time', true)==$thedate)
{ $counttest++;}
if (get_post_meta($post->ID,'film_time', true)==$thedate)
{ $counttest++;}
if (get_post_meta($post->ID,'artist_talk_time', true)==$thedate)
{ $counttest++;}
endwhile;
echo $counttest;
if ($counttest>=2){
echo ' Events ';
} // end if ($totalevents>=2) function
if ($counttest<2){
echo ' Event ';
}
echo $count;
if ($thedate==$today){echo 'Today';}
if ($thedate>$today){
echo $thedatetext;}
echo '<br>';
endif;
$counttest=0;
if ($event_query->have_posts()) : while ($event_query->have_posts()) : $event_query->the_post();
if (get_post_meta($post->ID,'opening_time', true)==$thedate)
{
?>
<a href="https://wordpress.stackexchange.com/questions/33636/<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('<h2>', '</h2>'); ?></a>
<h2>Opening Reception</h2>
<?php
echo get_post_meta($post->ID,'opening_time', true);
}
if (get_post_meta($post->ID,'artist_talk_time', true)==$thedate){ ?>
<a href="https://wordpress.stackexchange.com/questions/33636/<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('<h2>', '</h2>'); ?></a>
<h2> Artist Talk </h2>
<?php
echo get_post_meta($post->ID,'artist_talk_time', true);
}
endwhile;
endif;
rewind_posts();
}
?>