Thanks Angelo for responding. I tried your suggestion as follows but still get the same result.
$postType = get_post_type($postID); //returns event
if($postType != EM_POST_TYPE_EVENT)
return(array());
//$event = new EM_Event($postID, ‘post_id’); //old code is crashing here
$event = em_get_event($postID->ID, ‘post_id’); //new code is crashing here
$location = $event->get_location();
$arrEvent = $event->to_array();
$arrLocation = $location->to_array();
-Al
I think there is a difference in the code I shared vs your posted snippet?
eg.
my code $EM_Event = em_get_event($post->ID, 'post_id');
you code is $event = em_get_event($postID->ID, 'post_id');
OR your $post var is the variable $postID ? also, can I know if you are doing this in a wordpress template or separate custom php file
Hi. Yes, I use $postID instead of $post. It’s value is passed to my function as follows. My code is in separate php files for a plugin I’m developing.
public static function getEventPostData($postID){
$postType = get_post_type($postID); //returns event
if($postType != EM_POST_TYPE_EVENT)
return(array());
//$event = new EM_Event($postID, ‘post_id’); //old code is crashing here
$event = em_get_event($postID->ID, ‘post_id’); //new code is crashing here
$location = $event->get_location();
$arrEvent = $event->to_array();
$arrLocation = $location->to_array();
-Al
Solved. I needed to declare the $event variable before calling EM_Event. I don’t remember having to to do this before. I guess my host must be using newer PHP.
$event = null;
$event = new EM_Event($postID, ‘post_id’);
-Al