Support

Home Forums Event Espresso Premium DB Table field post_content not matching page content

DB Table field post_content not matching page content

Posted: December 7, 2018 at 8:27 am


ICLE

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!


ICLE

December 7, 2018 at 8:31 am

Sorry….we are running Event Espresso – 4.9.73.p on wordpress 5.


Josh

  • Support Staff

December 7, 2018 at 9:25 am

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:
http://demoee.org/use-cases/wp-json/ee/v4.8.36/events/3812

Here’s a link to the documentation about building REST API queries for events:
https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/README.md

Here’s an example plugin that adds a shortcode that can be used to display a list of events on an external site:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/shortcodes/jf_other_site_event_list.php


ICLE

December 10, 2018 at 12:46 pm

Josh,

Thank you for the help! The documentation for the API says:

Which fields are available for querying?
Use any field name of the entity you’re currently querying. For example, if querying for answers, you can either use “ANS_ID” or “ANS_value”. Please see the section on “Entities” to see what fields are available.

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


ICLE

December 10, 2018 at 1:37 pm

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?


Josh

  • Support Staff

December 10, 2018 at 3:07 pm

Can you send me a link please to where I can see what entities are available for query?

To see what entities exist, send a request to
https://{your domain}/wp-json/ee/v4.8.36/resources
you could open this link to see the resources from one of our servers:
https://demoee.org/use-cases/wp-json/ee/v4.8.36/resources

The above link is best opened using an app like Postman or similar.

Specifically, I want to return every event that is both “active” and “upcoming”

“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:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/shortcodes/jf_other_site_event_list.php#L17

Do you know if the API will return those fields we add via the plug-in?

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:

https://{site domain}/wp-json/ee/v4.8.36/events/{event ID}/post_metas


ICLE

December 18, 2018 at 7:21 am

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!


Josh

  • Support Staff

December 18, 2018 at 8:18 am

Hi,

The documentation shows how to use include followed by a comma separated list of related entities:
https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-GET-including-specific-fields-and-related-entities-in-results.md#ee4-rest-api-including-specific-fields-and-related-entities-in-results-for-get-request

e.g.
https://{your domain}/wp-json/ee/v4.8.36/events/{event ID}?include=Post_Meta.*,Registration.REG_final_price


ICLE

December 18, 2018 at 4:30 pm

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!


Josh

  • Support Staff

December 19, 2018 at 7:15 am

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:
/wp-json/wp/v2/taxonomies

When you view that discovery endpoint, you’ll see a list of all taxonomies, including espresso_event_categories and its items endpoint:
/wp-json/wp/v2/espresso_event_categories


ICLE

December 20, 2018 at 8:10 am

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!


Josh

  • Support Staff

December 20, 2018 at 8:24 am

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


ICLE

December 20, 2018 at 8:30 am

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.


Josh

  • Support Staff

December 20, 2018 at 1:05 pm

/wp-json/ee/v4.8.36/events?include=Term_Taxonomy.term_id

will do that.


ICLE

December 26, 2018 at 9:56 am

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?


Josh

  • Support Staff

December 26, 2018 at 10:56 am

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:
https://demoee.org/use-cases/wp-json/ee/v4.8.36/events?where[Datetime.DTT_EVT_start][%3E%3D]=2018-12-26T12:18:00&include=EVT_name,Datetime.DTT_EVT_start

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.

Event Espresso