0

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

  • I did not understand what you want to achieve - if `datumy` is ACF Repeater, then what are `datum_od` & `datum_do`? Can you explain little bit clear? – Outsource WordPress Jul 24 '18 at 10:42
  • sorry, yes `datumy` is ACF Repeater, and `datum_od` & `datum_do` is only simple date picker fields. And in WP you have option to set only date from - to, or more dates, some custom posts have only date from - to and some have 5 dates, and i need sort it from closet date. Its something like calendar. – Kevin Simkanič Jul 24 '18 at 11:08

1 Answers1

0

Thanks for interest, i solved this problem here is my solution for this if someone get same problem:

            $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 );