From what I understand you could do a query searching for all future events that are happening.
/**
* Agenda de eventos
*/
$today = date('Y-m-d');
$args = array(
'post_type' => 'post_talk', // seu post type
'posts_per_page' => -1,
'meta_key' => 'data_inicio', // ordena os eventos por data de inicio
'meta_type' => 'DATE',
'orderby' => 'meta_value',
'order' => 'ASC',
// busca todos os eventos que a data de termino seja maior ou igual a hoje
'meta_query' => array(
array(
'key' => 'data_fim',
'compare' => '>=',
'value' => $today,
'type' => 'DATE'
)
),
);
$talks = new WP_Query( $args );
To bring only events of the week you can combine one more meta_query:
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'data_fim',
'compare' => '>=',
'value' => $today,
'type' => 'DATE'
),
array(
'key' => 'data_inicio',
'compare' => '<=',
'value' => date('Y-m-d', strtotime('+1 week')), // +7 dias
'type' => 'DATE'
)
),
I’ll test it. Thank you.
– David Coelho
Not yet. :-(.
– David Coelho