Home Forums Event Espresso Premium Can't create instance of EE_Event since update`

Can't create instance of EE_Event since update`

Posted: May 10, 2018 at 7:50 am

Damian Way

May 10, 2018 at 7:50 am

Hi there,

I have some custom code that I wrote from various resources you have online and part of it populates a site search with various filters. It was all working ok up until our update today.

It is basically failing to create an instanceof EE_Event. I just wondered whether this was an issue that someone has seen before. The query returns the course information within the post details but fails to load the EE_Event object.

Here is a snippet of the code:

if (have_posts()) : while (have_posts()) : the_post();
$id = get_the_ID();
$post = get_post( $id );
$event_obj = $post->EE_Event;
if ( $event_obj instanceof EE_Event ) {
$venues_list = $post->EE_Event->venues();
foreach($venues_list as $venue){
$venues[$venue->identifier()] = array(‘ID’ => $venue->identifier(), ‘post_title’ => $venue->name());

$venues[] = array( ‘ID’ => ‘in-house’, ‘post_title’ => ‘At your premises (in-house)’);
$venues[] = array( ‘ID’ => ‘in-house’, ‘post_title’ => ‘At your premises only (in-house)’);

And here is an example of the post data that it is using:

object(WP_Post)#14343 (24) {
string(1) “2”
string(19) “2018-03-27 11:26:15”
string(19) “2018-03-27 10:26:15”
string(233) “Click for course information

Lots of practical work, and time to practise it! Engaging and enjoyable first aid course

string(50) “Emergency First Aid at Work in London (ref 18266E)”
string(0) “”
string(7) “publish”
string(6) “closed”
string(4) “open”
string(0) “”
string(48) “emergency-first-aid-at-work-in-london-ref-18266e”
string(0) “”
string(0) “”
string(19) “2018-03-27 11:26:15”
string(19) “2018-03-27 10:26:15”
string(0) “”
string(97) “”
string(15) “espresso_events”
string(0) “”
string(1) “0”
string(3) “raw”

Is this something that you guys can help me with?

Damian Way

May 10, 2018 at 8:21 am

I am guessing that this may be connected to the method I used for retrieving the events list. I am not converting this from using a deprecated method to using the EEM_Event::instance()->get_all() method but my understanding is a little limited. Are there any examples of how to retrieve all events by category slug?

My previous method for retrieving the events was:
function sts_get_courses_detail($category_slug = Null, $venue_slug = Null){
$atts = array(
'title' => NULL,
'limit' => 100,
'css_class' => NULL,
'show_expired' => FALSE,
'month' => NULL,
'category_slug' => $category_slug,
'order_by' => 'start_date',
'sort' => 'DESC'
// run the query
global $wp_query;
$wp_query = new EE_Event_List_Query( $atts );
return $wp_query;


  • Support Staff

May 10, 2018 at 1:42 pm

Hi Damian,

Thanks so much for providing the extra details. It looks like the custom code is using a deprecated classname. You can change this:

$wp_query = new EE_Event_List_Query( $atts );

to this:

$wp_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $atts );

and that should get things working the way they were before.

You must be logged in to reply to this support post. Sign In or Register for an Account

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

Updated by  Josh 2 weeks, 2 days ago ago

Topic Tags


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