the answer for all question about Oxygen Builder plugin and WordPress

Hi everyone,

Hi everyone,
I would like to build a repeater, which only shows upcoming events (posts) using Custom post types and ACF date picker. I think it maybe could be done by pre_get_post but I don’t know how – I’m quite newbie to this.
Is here anybody who has already solved this problem or is able to help me?
Thanks a lot



Source

2 Comments
  1. Blue Li says

    https://www.advancedcustomfields.com/resources/date-picker/
    There is a query example, try the below with advance query?

    ‘post_type’ => ‘event’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘start_date’,
    ‘compare’ => ‘<=', 'value' => $today,
    ),
    array(
    ‘key’ => ‘end_date’,
    ‘compare’ => ‘>=’,
    ‘value’ => $today,
    )
    ),

  2. David Webheld says

    Yes, I dont have the exact query at hand right now, but is is even possible without array in meta_query and just use meta_value and meta_key in combination with date-function. One very important thing in general to look at (and that I spend hours figuring out) is to make sure that ACF output of date picker is the same as how it is stored in the database. So use yyyy-mm-dd in the ACF-options. If you want a different output on frontend, you need to use a php-function around the get_field(date-field) to transform the date to your needs.

Leave A Reply

Your email address will not be published.

Oxyrealm Docs