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.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 1 week ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!