Support

Home Forums Event Espresso Premium EE3 Sorting and Filtering

EE3 Sorting and Filtering

Posted: April 1, 2015 at 8:00 am


djesse

April 1, 2015 at 8:00 am

Is there anyway to filter the event list to show only events with spaces available?
Also, need to be able to order the events by price.


Lorenzo Orlando Caum

  • Support Staff

April 1, 2015 at 8:32 am

Hi, there isn’t an built-in option to show events that have spaces available. This would require custom coding.

There are some sort options, however sort by pricing isn’t available. These are:

id
date(start_date)
date(end_date)
time(start_time)
time(end_time)
event_name
date(registration_start)
date(registration_end)
city
state
category_id
venue_title

https://eventespresso.com/wiki/shortcodes-template-variables/#event-list


Lorenzo


djesse

April 1, 2015 at 8:58 am

I’m trying with custom coding, but can never quite get it working.

Is it possible with the standard wp_query or does it require an SQL query statement?


Lorenzo Orlando Caum

  • Support Staff

April 1, 2015 at 11:42 am

Hi, a team member shared some sample code on making this change to the event_list.php file here:

https://eventespresso.com/topic/event-table-sorting-by-price/#post-69232


Lorenzo


djesse

April 1, 2015 at 12:48 pm

Hi,

That sample code just keeps throwing up ‘No events available…’


Dean

April 2, 2015 at 4:06 am

Hi,

You can use some existing code from the event_list_display.php and add it with a slight tweak to the event_list.php file to stop displaying event with no available spaces.

In the event_list.php at about line 326 you can add this:

$num_attendees = apply_filters('filter_hook_espresso_get_num_attendees', $event_id); 
if ($num_attendees >= $reg_limit) { continue; }

Here’s a screenshot of the code: http://take.ms/GXpnx

Here’s a general guide on customising templates in EE3 – https://eventespresso.com/wiki/put-custom-templates/


djesse

April 2, 2015 at 4:58 am

Hi, thanks for that.

It kind of works…
Is there something that kicks in before the query.
I need to use the Events-per-page attribute, so, if I have 10 events per page normally, this will show 3 on one page, then maybe 7 on another etc.

So by the time there may be only a couple of events with spaces left, I could end up with 4 blank pages before I get to the page with an available workshop on it.


Dean

April 2, 2015 at 5:04 am

Yeah, that’s the flaw with this system. Other than that you’re going to have to edit the SQL query or loop through the $events array after the SQL query spits it out and filter that directly.


djesse

April 2, 2015 at 5:25 am

Ah…
I’ve looked into editing the SQL query, for the price sorting, but always end up with ‘No available events’.
Are there any examples I could run some tests with?

The support post ‘EE3 Sorting and Filtering’ 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