Posted: July 16, 2014 at 4:12 am
|
Hi I am using a template in the theme but i need customize the following query, i know i can use the shortcode to pull the event list. I need to include the table to the query below. ( wp_term_relationships.term_taxonomy_id IN (19) ). SELECT SQL_CALC_FOUND_ROWS wp_posts.*, wp_esp_datetime.* , wp_esp_event_meta.* FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) WHERE 1=1 AND wp_posts.post_type = ‘espresso_events’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘cancelled’ OR wp_posts.post_status = ‘postponed’ OR wp_posts.post_status = ‘sold_out’ OR wp_posts.post_status = ‘private’) AND ( (wp_postmeta.meta_key = ‘sites-tag’ AND CAST(wp_postmeta.meta_value AS CHAR) LIKE ‘%%’) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10 ‘post_type’ => ‘espresso_events’, ‘compare’ => ‘Like’, The stand wordpress query uses the following which can pull the categories. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (3,27,28) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘private’) AND ( (wp_postmeta.meta_key = ‘sites-tag’ AND CAST(wp_postmeta.meta_value AS CHAR) LIKE ‘%%’) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10 If I can not use this way and have to revert back to the shortcodes, can i use meta query within the event list which can look at the meta_key meta_value. I need to add two custom adding fields for tagging so i can filter the event list depending on what tags they have use. |
|
Hi, I’m not 100% sure what you’re trying to achieve here, however Josh came up with a query code that might be of assistance. It leverage’s the EE4 functions that mimic core WP functions so no SQL required – https://gist.github.com/joshfeck/e3c9540cd4ccc734e755 |
|
Hi, I like to thank Josh in doing that for me, as that what i was looking for. I can work with this, many thanks. |
|
No problem, I’ll pass along your thanks. |
|
Hi, I successfully done the event list though I need to run the query that Josh supplied on Github on the calendar, how do i go about doing this? |
Hi James, I think you might be better off extending what the calendar plugin does because the calendar queries for datetimes instead of events. (An event can have more than one datetime). When you walk through the get_calendar_events method in EED_Espresso_Calendar.module.php, you’ll find that it has some category filtering going on, and it pulls in the datetime objects from EE core’s EEM_Datetime model. |
|
|
Hi Josh, I just look into that file, do i need to copy and paste the query over, does it need to be within the function below? public function run( $WP ) { |
Hi James, I don’t think you can copy that function over and it will just work outside of the calendar plugin. Instead you might try creating a new function that builds out your own version of the calendar shortcode and base your work off of the original. |
|
The support post ‘Event Query’ 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.