Home › Forums › Welcome! › Pre-Sales Questions › WP REST API V2 Endpoints for All Event Data?
- This topic has 4 replies, 3 voices, and was last updated 8 years, 1 month ago by Support Droid.
-
AuthorPosts
-
February 19, 2016 at 9:13 am #1078274MichaelParticipant
Hi,
How to pull in the data for events via the WP REST API V2 so that all of the data related to an event can be accessed? The event date isn’t being pulled in at http://www.contradodigital.com/wp-json/wp/v2/events/ (added this via the REST API Enabler plugin), likewise for the Venue information and all other information that is contained within the standard grey box area for an event.
Need to pull in this data for individual events and also via the ‘all events’ API URL.
Regards,
MichaelFebruary 19, 2016 at 12:28 pm #1078449BrianKeymasterHi,
Thanks for using our plugins. I can try to help out here.
We are not supporting the REST API until the rest of the endpoints are merged into core.
So I will try to help out, but I am limited in what I can do.
Since all our meta fields are protected (they start with _ ) by default the REST API ignores them.
I think this will work to unprotect the fields:
/**
* THe Events Calendar - Remove Protected Custom Meta for REST API
*/
add_filter( 'is_protected_meta', function( $protected, $meta_key ) {
if ( '_EventStartDate' == $meta_key || '_EventEndDate' == $meta_key || '_EventDuration' == $meta_key || '_EventVenueID' == $meta_key && defined( 'REST_REQUEST' )&& REST_REQUEST ) {
$protected = false;}
return $protected;
}, 10, 2 );
That is only a 4 of the fields, these two resources have more:
https://theeventscalendar.com/knowledgebase/wordpress-post-meta-data/
https://gist.github.com/jesseeproductions/c2df90a56827dae990a0
Once you do that you can utilize it more as in this guide:
This thread might help too:
https://theeventscalendar.com/support/forums/topic/any-wp-api-customization-to-get-day-events/
I can try to help out more, but limited in supporting this until we add it into our plugin.
Thanks
February 22, 2016 at 5:01 am #1079650MichaelParticipantThanks Brian, this should suffice for now, I’ll have a play.
In terms of rough timelines for expecting all end points to be supported through the API? I know this is hugely reliant on the core WP team, with their focus at the minute I can’t imagine it being longer than a few months? Is that optimistic do you feel?
I’d rather not go creating lots of customisations which are ultimately going to be overridden in a few months as support is added from Core WP team in the API and The Events Calendar team. Wondering what to do VS what to wait for until things are updated.
Regards,
MichaelFebruary 22, 2016 at 7:36 am #1079756BrianKeymasterHi,
Unforutnaly, I do not have a timeline to give out for when we might support it.
I would give unique names to your custom solution so that it will continue to work even once it is in Core and we add our own support for it.
March 8, 2016 at 8:35 am #1086256Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘WP REST API V2 Endpoints for All Event Data?’ is closed to new replies.