How to Add Extra Event Data to the JSON Output
Last Updated: November 12, 2021
The API addon is the go-to addon when you are looking to add extra meta data to the JSON array. In the below example we are going to add a subtitle for an event in the JSON data output.
To get started with this, paste this code into your main theme’s functions.php file
add_filter('evoapi_event_data', 'evoapi_add_moredata', 10, 3); function evoapi_add_moredata($event_data, $event_id, $event_pmv){ if(!empty($event_pmv['evcal_subtitle'])){ $event_data['subtitle'] = $event_pmv['evcal_subtitle'][0]; } return $event_data; }
You can then make any other adjustments to this code. You can find all event post meta variable names here http://www.myeventon.com/documentation/event-post-meta-variables/
Once this is done the JSON string will include the subtitle field as you can see below.
Did this article help you?