Support

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

Viewing 2 reply threads


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;
var_dump($event_obj);
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());
}
}

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

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

object(WP_Post)#14343 (24) {
[“ID”]=>
int(6277)
[“post_author”]=>
string(1) “2”
[“post_date”]=>
string(19) “2018-03-27 11:26:15”
[“post_date_gmt”]=>
string(19) “2018-03-27 10:26:15”
[“post_content”]=>
string(233) “Click for course information

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


[“post_title”]=>
string(50) “Emergency First Aid at Work in London (ref 18266E)”
[“post_excerpt”]=>
string(0) “”
[“post_status”]=>
string(7) “publish”
[“comment_status”]=>
string(6) “closed”
[“ping_status”]=>
string(4) “open”
[“post_password”]=>
string(0) “”
[“post_name”]=>
string(48) “emergency-first-aid-at-work-in-london-ref-18266e”
[“to_ping”]=>
string(0) “”
[“pinged”]=>
string(0) “”
[“post_modified”]=>
string(19) “2018-03-27 11:26:15”
[“post_modified_gmt”]=>
string(19) “2018-03-27 10:26:15”
[“post_content_filtered”]=>
string(0) “”
[“post_parent”]=>
int(0)
[“guid”]=>
string(97) “https://stsfirstaid.staging.wpengine.com/events/emergency-first-aid-at-work-in-london-ref-18266e/”
[“menu_order”]=>
int(0)
[“post_type”]=>
string(15) “espresso_events”
[“post_mime_type”]=>
string(0) “”
[“comment_count”]=>
string(1) “0”
[“filter”]=>
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;
}


Josh

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

Viewing 2 reply threads

The support post ‘Can't create instance of EE_Event since update`’ 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