Support

Home Forums Event Espresso Premium Event Query

Event Query

Posted: July 16, 2014 at 4:12 am


James Miller

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’,
//’cat’ => ’19’,
//’category_name’ => $event_topic_cat,
‘term_id’ => 19,
//’category_name’ => ‘general-1403607004’,
‘paged’ => $paged,
‘meta_query’ => array (
array (
‘key’ => ‘sites-tag’,
‘value’ => $event_filter_site,
// ‘value’ => ‘”finest”‘,

‘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.


Dean

July 16, 2014 at 11:56 pm

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


James Miller

July 17, 2014 at 5:04 am

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.


Dean

July 17, 2014 at 5:09 am

No problem, I’ll pass along your thanks.


James Miller

July 18, 2014 at 9:42 am

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?


Josh

  • Support Staff

July 18, 2014 at 1:06 pm

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.


James Miller

July 21, 2014 at 2:40 am

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 ) {
// add_filter( ‘FHEE_run_EE_wp’, ‘__return_true’ );
// add_filter( ‘FHEE_load_EE_Session’, ‘__return_true’ );
// add_action( ‘wp_loaded’, array( $this, ‘wp_loaded’ ));
// add_action( ‘wp’, array( $this, ‘wp’ ));
// add_filter( ‘the_content’, array( $this, ‘the_content’ ));
}


Josh

  • Support Staff

July 21, 2014 at 9:19 am

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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Josh 5 years, 1 month ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!