Support

Home Forums Community Forum Access event start time whilst looping on get_posts();

Access event start time whilst looping on get_posts();

Posted: June 23, 2016 at 4:59 am


LFell

June 23, 2016 at 4:59 am

I have the following get_posts function:

$relatedevents = get_posts(array(
	'post_type' => 'espresso_events',
	'suppress_filters' => false,
	'posts_per_page' => '3',
	'meta_query' => array(
		array(
			'key' => 'related_sidbear_page_link', // name of custom field
			'value' =>  get_the_ID(),
			'compare' => 'LIKE'
		)
	),
	'tax_query' => array(
		array(
			'taxonomy' => 'espresso_event_categories',
			'field' => 'term_id',
			'terms' => 139
		)
	)
));

Which works well, however, when I’m looping the results I need to access the Event Start date, however the event start date is protected:

foreach( $relatedevents as $relatedevent ):
										
	$event_obj = $relatedevent->EE_Event;
	$datetimes = $event_obj->datetimes_ordered();
					
	echo "<pre>";
	var_dump($datetimes);
	echo "</pre>"; 
endforeach;

Is anyone aware of a method which will allow me to access the start date?

The support post ‘Access event start time whilst looping on get_posts();’ 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