I'm struggling to get a working solution with wp_query for Event management, Currently post order by event start date & time work well. Now I want some custom settings.
Have two meta boxes working with
meta_key=> start_datetime
andmeta_key=> end_datetime
1- key=> end_datetime
is a date and time for the post to end (no longer display in the results)
2- Additionally print some text in posts as two hours remain to start event. e.g <p>LIVE</p>
How to hide post when date&time end, and add some text as remain 2 hours to start?
$today = date("Y/m/j");
$args (array(
'post_type' => 'event',
'posts_per_page' => 10,
'meta_key' => 'start_datetime',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'start_datetime',
'value' => $today,
'compare' => '>=',
'type' => 'CHAR'
)
),
'tax_query' => array(
'relation' => 'AND',
array(
'key' => 'end_datetime',
'meta-value' => $value,
'compare' => '=<'
)
)
));
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
the_title();
}
}
relation
in the query.