Support

Home Forums Event Espresso Premium EE4 JSON REST categories question

EE4 JSON REST categories question

Posted: November 21, 2015 at 8:49 am

Viewing 6 reply threads


Brandon Gannon

November 21, 2015 at 8:49 am

I’m trying to figure out the JSON REST stuff and when I try to learn something, I find it’s best to have a project goal.
So my goal is to make a page that I can’t figure out another way to make: A List of EE Categories, each with a list of events in that category.
My problem is that I can’t figure out WHERE the EE categories are in the JSON data. How do I call them? Use them?
Maybe it’s in posts meta, which apparently I don’t have permission for? How to grant permission for that?
So many questions, I know.
Thanks in advance for your patience.

FYI, I’ve installed WP JSON REST plugin and EE JSON REST addon and also the CLIENT addon from the Github. I’ve got it working and am trying to modify it for my own (and client’s) needs.

The template currently has:
<article ng-repeat=”event in events”>
<h2>”{{ event.link }} {{ event.EVT_name }}</h2>
</article>

I want it to have something like:
<article ng-repeat=”event in events”>
<h2>{{ event.EVT_category }}</h2>

  • {{ event.link }} {{ event.EVT_name }}

</article>

And of course, I want it to loop through the categories and then loop through the events in each category.

THANKS!


Brandon Gannon

November 23, 2015 at 8:36 am

I’m getting closer. I’ve found this:
“terms”: {
“espresso_event_categories”:
[
{
“ID”: ​207,
“name”: “Classes”,
“slug”: “classes”,
“description”: “”,
“taxonomy”: “espresso_event_categories”,

But I’m still trying to find out how to reference that.


Brandon Gannon

November 23, 2015 at 9:03 am

I’m also finding that when my JSON data is from:
MYDOMAIN/wp-json/posts?filter[post_type]=espresso_events
a. The TERMS data is available
b. It doesn’t filter to EE posts (they’re not included and all other posts are)

But when I get JSON data from:
MYDOMAIN/wp-json/ee/v4.6/events/
a. The TERMS are not available
b. It does filter the EE posts properly (All EE Events are included and no other post types)


Josh

  • Support Staff

November 24, 2015 at 1:19 pm

Hi Brandon,

You can get a list of EE event categories (or terms) with this:

/wp-json/taxonomies/espresso_event_categories/terms

There’s a lot of good information here:
http://wp-api.org/#taxonomies_retrieve-a-taxonomy-term

Once you have your list of EE event category terms, you can get a filtered list of events by event category with this:

/wp-json/ee/v4.6/events/?filter[where][Term_Taxonomy.Term.slug]=your-category-slug&include=EVT_name

More info here:
http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#GETting_Results

  • This reply was modified 8 years, 10 months ago by Josh. Reason: no links, bbpress


Brandon Gannon

November 24, 2015 at 4:41 pm

Perfect! Thanks!


Brandon Gannon

November 24, 2015 at 4:52 pm

One correction to your JSON URL above: needs brackets:

/wp-json/ee/v4.6/events/?filter[where][Term_Taxonomy.Term.slug]=classes-for-teens&include=EVT_name


Josh

  • Support Staff

November 25, 2015 at 8:50 am

Fixed. We can thank bbPress for stripping those out.

Viewing 6 reply threads

The support post ‘EE4 JSON REST categories question’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso