Support

Account

Home Forums Add-ons Repeater Field Events Calendar – Repeating Event Dates

Solved

Events Calendar – Repeating Event Dates

  • I’m building a basic events calendar and want to create repeating events by using a repeater field for which the user can select a date, adding as many as desired.

    The meta data is set out like this in the database;

    event_dates_1_repeat_date
    event_dates_2_repeat_date
    etc…

    How would I dynamically query these fields?

    $args = array(
       'post_type' => 'post',
       'posts_per_page' => -1,
       'order' => 'ASC',
       'orderby' => 'meta_value_num',
       'meta_key' => 'event_start_time',
       'meta_query' => array(
         'relation' => 'OR',
         array(
           'key' => 'event_date',
           'value' => $search_day
         ),
         array(
           'key' => 'event_dates_1_repeat_date',
           'value' => $search_day
         ),
         array(
           'key' => 'event_dates_2_repeat_date',
           'value' => $search_day
         )
       )
    );
  • Turns out to be quite easy…

    array(
       'like' => 'event_dates_%_repeat_date',
       'value' => $search_day
    )
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.