Support

Home Forums Event Espresso Premium Query Broken after Upgrade to 4.9.39.p

Query Broken after Upgrade to 4.9.39.p

Posted: June 3, 2017 at 9:12 pm

Viewing 2 reply threads


karks88

June 3, 2017 at 9:12 pm

Hi, I had been using an old EE_Event_List_Query on my client’s home page to get the next 3 upcoming events. Each event displayed the Event Name, Link, Date and Thumbnail.

Upgrading EE4 to 4.9.39.p seems to have broken that query. I’ve since moved on to the following, but for some reason cannot get the date to display at all (the page display gets thrown off and no dates are shown):

<?php
// set up show expired = false
$where = array(
	'Datetime.DTT_EVT_end' => array( '>=', current_time( 'mysql' )),
	'status' => 'publish',
);
// run the query
if ( class_exists( 'EE_Registry' ) ) :
// Load Event View Helper
EE_Registry::instance()->load_helper('Event_View');
$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
	$where,
	'limit' => 3,
	'order_by' => 'Datetime.DTT_EVT_start',
	'order' => 'ASC',
	'group_by' => 'EVT_ID'
));
// the loop
if ( ! empty( $events )) {
	foreach ( $events as $event ) {
	
	
	
		if ( $event instanceof EE_Event ) {
			echo '<div class="column one_fourth" style="margin-right:0%;">';
			echo '<h4><a href="' . get_permalink( $event->ID() ) . '">' . $event->name() . ' &raquo;</a></h4>';
			echo '</div>';
		 }
	}
} 
endif; ?>   

Do you have any suggestions on how I might get the date and thumbnail in this query? I’ve done some searching but everything I try seems to produce this same crash, with no errors in the console.


Josh

  • Support Staff

June 5, 2017 at 10:47 pm

Hi there,

I can suggest using the model system. You’ll find some documentation here:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-querying.md

There isn’t much in examples there, so here’s an example that’s similar to the code you’re working with:

https://gist.github.com/joshfeck/0ac4ccfadc051d30fce561aab8ea59d1


karks88

June 6, 2017 at 11:00 am

Hi Josh, thanks so much for your help. This is exactly what I needed!

Viewing 2 reply threads

The support post ‘Query Broken after Upgrade to 4.9.39.p’ 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