Support

Account

Home Forums Add-ons Repeater Field Wp_Query: Filter by ACF Reapeter Date

Unread

Wp_Query: Filter by ACF Reapeter Date

    • roby492

    • September 12, 2020 at 12:23 am

    Hi all,
    I’m trying to filter with WP_Query custom post “courses” base of dates of repeater field.

    My repeater is called “dates” and contains three subfields:
    – date
    – Start time
    – End time

    I have added this snippet of code on my functions.php:
    function my_posts_where( $where ) {
    $where = str_replace(“meta_key = ‘dates%”, “meta_key LIKE ‘dates%”, $where);
    return $where;
    }
    add_filter(‘posts_where’, ‘my_posts_where’);

    $args = array(
    ‘post_type’ => ‘webinar’,
    ‘posts_per_page’ => -1,
    // ‘post__not_in’ => array(get_the_ID()),
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘menu_order’,
    ‘meta_query’ => array(
    ‘relation’ => ‘AND’,
    array(
    ‘key’ => ‘dates%date’,
    ‘compare’ => ‘>=’,
    ‘value’ => date(‘Ymd’),
    )
    )
    );

    I need to select posts that have at least one of date inside the repeater
    after today’s date.

    Thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.