shooin
September 2, 2020 at 6:05 am
Hello, I am trying to get the date to show on a Elementor widget and I was told to add this to the fucntion but I am not sure how to query the date. \
add_filter( ‘uael_post_event_date’, function( $date, $post_id, $date_format ) {
$event_date = get_post_meta($post_id, ‘event_date’, true);
return $event_date;
}, 10, 3 );
I need to replace ‘event_date’ with somthing that will pull in the Event Expresso date.
Any help is appreciated.
Thanks
ShooMoe
Tony
September 3, 2020 at 7:21 am
Add New Note to this Reply
Hi ShooMoe,
The easiest way to do this is by using our model system, which we have details on here:
https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System
To give you a working example, something like this should do that you are requesting:
add_filter( 'uael_post_event_date', function( $date, $post_id, $date_format ) {
$event = EEH_Event_View::get_event($post_id);
if ($event instanceof EE_Event) {
$datetime = $event->primary_datetime();
if ($datetime instanceof EE_Datetime) {
return $datetime->get_i18n_datetime('DTT_EVT_start', $date_format);
}
}
return $date;
}, 10, 3 );
Note – the above is untested.