Posted: December 7, 2018 at 8:27 am
I have to develop queries to pull event information directly from the database for display on an external site. I have located the event name in the _posts table in the post_title field. The description of the event appears to be stored in the post_content field of the _posts table. However, the post_content column contains 6 or 8 html DIV wrapper tags around the actual content. When I inspect the content on the wordpress page those wrapper DIV tags are not part of the html. There is only one matching record in the _post table so I have to be looking at the correct record. I am trying to understand what happened to all of the html that appears to have been stripped out. I don’t want or need that html for my purposes but I am wondering if there is perhaps another table besides _posts where this event description is coming from? My other question is, is there someplace in the php code that I can find the queries being run that generates the content on the event page? Thank you! |
|
Sorry….we are running Event Espresso – 4.9.73.p on wordpress 5. |
|
Hi, Quite likely, a filter on the_content stripped the html before it’s output to the web page. Sometimes a theme will do that. What you could do instead, since this is an external site, is use the REST API to pull that information. Here’s an example of a REST API request to our demo site: Here’s a link to the documentation about building REST API queries for events: Here’s an example plugin that adds a shortcode that can be used to display a list of events on an external site: |
|
Josh, Thank you for the help! The documentation for the API says: Which fields are available for querying? But nowhere does the documentation give any clue on where to look for the entities. Can you send me a link please to where I can see what entities are available for query? Specifically, I want to return every event that is both “active” and “upcoming” Thank you |
|
One more question. We installed the “advanced custom fields” plug-in. Do you know if the API will return those fields we add via the plug-in? |
|
To see what entities exist, send a request to The above link is best opened using an app like Postman or similar.
“active” and “upcoming” are not actually event entities. The code I shared with you shows exactly how to get activate and upcoming events, specifically this line:
Yes, it does. Post Meta fields are protected so you’ll need to include some authorization with the request. Event Espresso includes the Basic Auth plugin so if the request includes Basic Auth headers, you can do something like this to get an event’s custom fields:
|
|
By googling I found that I can call the API with: /wp-json/ee/v4.8.29/events?include=Post_Meta and it will include the custom fields in the original API call and I don’t have to recurse down the tree to get at that data. However, I am not seeing, for example, the ticket prices coming back. It looks like I would have to do another API call to: https://{my domain}/wp-json/ee/v4.8.29/events/{event ID}/registrations Is there another include keyword that will give me that information without having to make a second API call? I’m trying to get all data for an event on 1 call to avoid performance issues. Thank you! |
|
Hi, The documentation shows how to use e.g. |
|
I have found the taxonomy term IDs for my event. Let’s say I have taxonomy espresso_event_categories with term ID 2. I need to get the friendly name for term ID 2. Is there an API call that will give me a list of all of the espresso_event_categories with term ids at one time? I want to stuff that away in memory and then whenever I have a term id I can find the friendly name in memory rather than having to run an API call to resolve the term ID to it’s friendly name. I tried this: /wp-json/ee/v4.8.29/taxonomies/espresso_event_categories/terms But it returned no route. I read through all of the API documentation but found nothing on how to get the friendly names for the event category taxonomy IDs. I need to do the same for the type taxonomy IDs assigned to the event. Thanks! |
|
Hi, Since taxonomies are a core WordPress feature, their API endpoints are documented here: https://developer.wordpress.org/rest-api/reference/taxonomies/ Like other REST API endpoints, you can use the discovery endpoints to see how to build your requests. For example the above linked documentation shows the discovery endpoint: When you view that discovery endpoint, you’ll see a list of all taxonomies, including |
|
Thanks, Josh. I am able to use the API to get a list of all of the terms that are defined. What I am running into a problem with is finding the term ID that is assigned to an event. We have an espresso event category called “Live” which has a term ID value of 13. I call the API with the following: /events?include=Post_Meta,Datetime.Ticket.*,Venue.*,Term_Taxonomy.*,Term.*,Term_Relationship.* There is a term_relationships and a term_taxonomies that is part of the results from the API call. Apparently the term.* doesn’t show in the response. I need to identify in the response where I can find term id 13 assigned to the specific event. Another event might have term id 12 assigned to it. Some events have multiple term ids assigned to them. term_relationships has term ids in the results but it might show 5 terms listed where I know there is only one term assigned. So that can’t be the right field to find the term id assigned to an event. Same with term_taxonomies in the results. I’ve googled and dug through the docs but no luck finding out how I go about getting the term id assigned to a specific event. Appreciate any suggestions you have! |
|
What you can do is add a where clause so the list returns only events with term taxonomy ID of 13, e.g.: wp-json/ee/v4.8.36/events?where[Term_Taxonomy.term_id]=13 |
|
Thanks for the suggestion but unfortunately that won’t work for my needs. I am retrieving all events from the current date forward. What I need to do is loop through each event and as part of that process grab the term id(s) assigned to the event. Then using that term id I can look up the friendly name for the term and display it on a page along with the rest of the info for the event. I need to know how hot get the assigned category term ID(s) from the events data. |
|
will do that. |
|
I created a current date value string using this format: 2018-12-26T11:44:59 All the examples seem to use that format for the date/time. I’m trying to query the API where I want to retrieve all events in the future. I’m using this format: events?where[Datetime.DTT_EVT_start][>=]=#currDate# and it doesn’t work at all. I’ve tried putting the date in single quotes, I’ve tried various iterations of different syntax, nothing seems to work. I’ve googled and reviewed all the examples I could find. Can you tell me what I’m doing wrong please? |
|
Hi, The documentation mentions that “you may need to url-encode operators”, so here’s an example that includes a url-encoded operator that gets upcoming events from our demo site: |
|
The support post ‘DB Table field post_content not matching page content’ 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.