I have a minor problem, I need to solve the following:
$today = current_time('Ymd');
$args = array(
'post_type' => 'event',
'posts_per_page' => 3,
'meta_query' => array(
'relation' => 'OR',
'datumOd' => array(
'key' => 'datum_od',
'value' => $today,
'compare' => '>=',
),
'datumDo' => array(
'key' => 'datum_do',
'value' => $today,
'compare' => '>=',
),
'datumy' => array(
'key' => 'datumy'
)
),
'orderby' => array(
'datumOd' => 'ASC',
'datumDo' => 'ASC',
'datumy' => 'ASC'
),
);
$events = new WP_Query( $args );
"datumy" are the acf repeater with the date picker in which the dates are. I need to think of something that I can check if the date in my repeater has already occurred and that is still happening and what happens to add them to the loop.
Example:
current day: 10.8.2018
"datum_od" = 13.08.2018 - post with one date
"datum_od" = 20.08.2018 - post with one date
"datum_od" = 15.09.2018 - post with one date
"datumy" = array (1.8.2018, 26.8.2018, 2.9.2018) - post with multiple dates
and the "datumy" I need to check, 1.8.2019 has already been so hiding the date, and to see the date 26.8.2018 plus place it in the correct order where it should be with the date.
Would something like that be possible? Would anyone know how to help me? Or maybe direct me to the right path?
Thank you very much
答案 0 :(得分:0)
感谢您的关注,我解决了这个问题,如果有人遇到同样的问题,这是我的解决方案:
$second = array();
for ($i = 1; $i <= 10; $i++) {
$datumy = ( 'Datumy' . $i );
$datumDB = ('datumy_' . $i . '_datum');
$second += array(
$datumy => array(
'key' => $datumDB,
'value' => $today,
'compare' => '>=',
),
);
}
$args['meta_query'] = array_merge( $args['meta_query'], $second );