Working on upcoming events list that returns posts fine in a custom query. In the custom post type 'event' there are multiple events within a date range. I want to display all upcoming events in order. This I can do but I also want to count the events for each day.
Right now I am using found_posts to return the post count from the query but that misses posts that have two or more meta_keys filled in. How do I get an accurate count of events for both meta_keys - opening_time and artist_talk time?
The goal is to publish one custom post for an event that has a permalink with all the information. Each custom post has meta boxes that can be filled it with the date range for the beginning and end of the event (usually runs for a month or two) as well as dates for activities that are one day only during the run of the event. Opening Night, Lectures, Films .... that have their own meta box fields. Not all events have all activities.
I want to have the upcoming event list count the number of "activities" that happen on a certain day not count the CPT events. Each activity will list its type as an H2 and then the title that will link to the permalink of the Event with all the information.
Thank you in advance.
<?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 );
$event_query = new WP_Query(
array(
'post_type' => 'event',
'meta_key' => 'opening_time',
'orderby' => 'meta_value',
'order' => 'asc',
'meta_query' => array(
array(
'key' => 'opening_time',
'value' => $thedate,
'compare' => 'LIKE',
'type' => 'DATE'
) // end array
) // end 'meta_query' arrayx
) // end array
); // end top array
if ($event_query->have_posts()){
echo $event_query->found_posts;
$totalevents=$event_query->found_posts;
if ($totalevents>=2){
echo ' Events ';
} // end if ($totalevents>=2) function
if ($totalevents<2){
echo ' Event ';
}
if ($thedate==$today){echo 'Today';}
if ($thedate>$today){
echo $thedatetext;}
echo '<br>';
}
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="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('<h2>', '</h2>'); ?></a>
<h2>Opening Reception</h2>
<?php
}
if (get_post_meta($post->ID,'artist_talk_time', true)==$thedate){ ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('<h2>', '</h2>'); ?></a>
<h2> Artist Talk </h2>
}
endwhile;
endif;
rewind_posts();
}
?>