Support

Home Forums Event Espresso Premium Add custom meta and use it as filter in EE calendar

Add custom meta and use it as filter in EE calendar

Posted: February 23, 2021 at 10:33 am


MelG

February 23, 2021 at 10:33 am

Please let us know how can we add a meta custom field like “Language” for example, to each event, and then use it as a filter for the EE calendar.
We guess we can use the custom meta in WP and add the meta field, but what is the best way to use this field as a filter after that?

Thank you!

SC


Tony

  • Support Staff

February 24, 2021 at 7:00 am

Hi there,

In terms of using altering the query params used to pull in the datetimes, we have a filter for that:

FHEE__EED_Espresso_Calendar__get_calendar_events__query_params

That filter is passed the query params used by out model system (See the docs HERE) and some additial values:

$datetime_objs = EEM_Datetime::instance()->get_all(
    apply_filters(
        'FHEE__EED_Espresso_Calendar__get_calendar_events__query_params',
        array( $where_params, 'order_by'=>array( 'DTT_EVT_start'=>'ASC' ) ),
        $category_id_or_slug,
        $venue_id_or_slug,
        $public_event_stati,
        $start_date,
        $end_date,
        $show_expired
    )
);

The calendar pulls datetimes using EEM_Datetime, so to pull datetimes related to events with a specific post meta key/value, you can do something like this:

https://gist.github.com/Pebblo/e6fb95448cf2dd6965fbc9cc1215e5be

Which will work for events with a custom meta key of ‘Language’ and value ‘English’, you’ll need a way to dynamically set that value on the page to use within the filter but I’m assuming you already have that.

The support post ‘Add custom meta and use it as filter in EE calendar’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso