Hi there, I have a custom post type “EVENTS” with an ACF date field, what I need is to build and archives page so when the event has passed I need to disappear from the Archive page.
I have this code in my functions.php
/*CUSTOM ARCHIVE FOR EVENTS*/
function events_pagesize( $query ) {
// exit out if it's the admin or it isn't the main query
if ( is_admin() || ! $query->is_main_query() )
return;
// so its not admin, and its the main query, is it the tr-events post archive?
if ( is_post_type_archive( 'evento' ) ) {
// it is!! Set the posts_per_page to 6
$query->set( 'posts_per_page', 6 );
$query->set( 'order' , 'ASC' );
$query->set( 'meta_key', 'fecha');
$query->set( 'orderby', 'meta_value_num');
$query->set( 'meta_compare', '>');
$query->set( 'meta_value', date("Ymd"));
return;
}
}
But this makes the event disappear the same date I choose in the admin, I need to go away the same day at 00h.
Thanks
$query->set( 'meta_compare', '>=');