I am using elementor loop builder to make a custom events template. I can grab the event name easy enough and link it, but can't find the meta name for the month and separately the date. I am going to display these stacked beside the event name. Do you have a list of the stec meta data that I can pull in using the post meta?
So is there anyway to add this to my functions.php and have it setup some meta data for all events? So I can pull that meta key into the elementor loop as needed?
What you could do is to store the values in custom meta upon event save.
Place the following code in your child-theme functions.php file:
/**
* Add custom post meta to event
* Store event day number, day label and month label in post meta
* @param int $result - post id
* @param Event $event
* @param bool $is_update
* @return void
*/
add_action('stec_after_insert_event', function ($result, $event, $is_update) {
if ( ! is_numeric($result)) {
return;
}
$day_num = $event->get_start_date('d');
$day_label = $event->get_start_date('l');
$month_label = $event->get_start_date('F');
update_post_meta($result, 'stec_event_day_num', $day_num);
update_post_meta($result, 'stec_event_day_label', $day_label);
update_post_meta($result, 'stec_event_month_label', $month_label);
}, 10, 3);
Now when you save/update an event a new meta keys will be added
Okay 1 more question. I can see the link meta but it is an array and when I select that meta for a elementor button, it causes a critical error. So is there a way to just grab the external url from an event so I can use it in a loop grid as needed. Assuming there is a way with some custom php work as you've given before.
and then you can use the stec_event_link_url meta key to get the value of the url.
/** * Add custom post meta to event * Store event day number, day label, month label and externa link url in post meta * @param int $result - post id * @param Event $event * @param bool $is_update * @return void */ add_action('stec_after_insert_event', function ($result, $event, $is_update) { if ( ! is_numeric($result)) { return; } $day_num = $event->get_start_date('d'); $day_label = $event->get_start_date('l'); $month_label = $event->get_start_date('F'); update_post_meta($result, 'stec_event_day_num', $day_num); update_post_meta($result, 'stec_event_day_label', $day_label); update_post_meta($result, 'stec_event_month_label', $month_label); update_post_meta($result, 'stec_event_link_url', $event->get_link('url')); }, 10, 3);
I am using elementor loop builder to make a custom events template. I can grab the event name easy enough and link it, but can't find the meta name for the month and separately the date. I am going to display these stacked beside the event name. Do you have a list of the stec meta data that I can pull in using the post meta?
Hi,
Here's example how you can obtain the meta:
As an alternative just use
Stachethemes Developer
Thank you for the response.
So is there anyway to add this to my functions.php and have it setup some meta data for all events? So I can pull that meta key into the elementor loop as needed?
What you could do is to store the values in custom meta upon event save.
Place the following code in your child-theme functions.php file:
Now when you save/update an event a new meta keys will be added
Stachethemes Developer
You rock man, thanks! This works well. It is okay if not, but anyway you'd be able to abbreviate the month label so everything is 3 characters?
Sure, replace
with:
Stachethemes Developer
Okay 1 more question. I can see the link meta but it is an array and when I select that meta for a elementor button, it causes a critical error. So is there a way to just grab the external url from an event so I can use it in a loop grid as needed. Assuming there is a way with some custom php work as you've given before.
I am afraid you will have to add one additional line to the hook I've sent you earlier:
and then you can use the stec_event_link_url meta key to get the value of the url.
Stachethemes Developer