I'm trying to display past and future events using a wordpress query. I'm able to query future events and even events that are on the same date as the current date.
But, when i use less than or equals to in the query, nothing returns at all.
Here's the frontend for reference. /
<?php
$terms = get_the_terms( $post->ID , 'event_speaker', 'string');
//Pluck out the IDs to get an array of IDS
$term_ids = wp_list_pluck($terms,'term_id');
$current = current_time( 'Y-m-d' );
$the_query = new WP_Query( array(
'post_type' => 'tribe_events',
'meta_key' => '_EventStartDate',
'tax_query' => array(
array (
'taxonomy' => 'event_speaker',
'field' => 'id',
'terms' => $term_ids,
'operator'=> 'IN' //Or 'AND' or 'NOT IN'
)
),
'meta_query' => array(
array(
'key' => '_EventStartDate',
'value' => $current,
'compare' => '<=',
'type' => 'DATE'
),
)
) );
while ( $the_query->have_posts() ) :
$the_query->the_post(); ?>
<div class="upcoming-events">
<h2><?php the_title(); ?><br><?php echo tribe_get_start_date(); ?> - <?php echo tribe_get_end_time(); ?></h2>
</div><!-- upcoming events-->
<?php endwhile;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata(); ?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745273032a4619866.html
评论列表(0条)