Support

Home Forums Event Espresso Premium EE4 Sort category listing results by time

EE4 Sort category listing results by time

Posted: August 26, 2014 at 10:10 am


james thrift

August 26, 2014 at 10:10 am

Hi

Have events entered over 5 days and am using the Event Category as a menu listing. While it sorts the events ok by date, it shows the results in a random time order. How can I get it to order by Time and Date. Thanks.

WordPress Version:
3.9.2
PHP Version:
5.4.31
MySQL Version:
5.5.36
Event Espresso Version:
4.3.0.p


Lorenzo Orlando Caum

  • Support Staff

August 26, 2014 at 11:15 am

Hi,

Are you using this shortcode?

[ESPRESSO_EVENTS category_slug=”free-events” order_by=”start_date,id”]


Lorenzo


james thrift

August 26, 2014 at 11:28 am

That short code works in that the events are in the right order, but it creates a page with an enormous event picture and no event information, while using the Appearance>Menus>Event Categories creates a perfect layout of picture and event information, just in the wrong order.


Lorenzo Orlando Caum

  • Support Staff

August 26, 2014 at 2:28 pm

Is the event categories page showing the events in reverse chronological order?


Lorenzo


james thrift

August 26, 2014 at 2:35 pm

No, somewhat random. Here is one page http://www.sherborneliterarysociety.com/event-category/member-festival-wednesday/


Dean

August 27, 2014 at 2:19 am

Hi James,

The only way to achieve what you are after is to modify the template files.

Copy these files to your theme folder

/wp-content/plugins/event-espresso-core-reg/templates/Espresso_Arabica_2014/archive-espresso_events.php
/wp-content/plugins/event-espresso-core-reg/templates/Espresso_Arabica_2014/loop-espresso_events.php

Copy the function from this file to your themes functions.php
/wp-content/plugins/event-espresso-core-reg/templates/Espresso_Arabica_2014/functions.php

In the loop-espresso_events.php above the if have posts section add

if( is_tax() ) {

	$cat = single_cat_title( '', false );

	if($cat != '') { $cat = strtolower( str_replace(' ', '-', $cat ) ); } else { $cat = NULL; }


	$atts = array(
		'title' => NULL,
		'limit' => 100,
		'css_class' => NULL,
		'show_expired' => FALSE,
		'month' => NULL,
		'category_slug' => $cat,
		'order_by' => 'start_time',
		'sort' => 'ASC'
	);
	// run the query
	global $wp_query;
	$wp_query = new EE_Event_List_Query( $atts );

}



At the bottom of the page add

// now reset the query and postdata
wp_reset_query();
wp_reset_postdata();

That should make it so that the /event-category/my-category-name/ events will be ordered by time.

You may still need to style them though, just like you would have to with the shortcode.

The support post ‘EE4 Sort category listing results by time’ 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