Support

Home Forums WP User Integration My Events Page sort and filter

My Events Page sort and filter

Posted: April 14, 2014 at 6:43 pm

Viewing 8 reply threads


Trevis

April 14, 2014 at 6:43 pm

Wondering how to do a couple of things:

When inserting the shortcode for this, I’m trying to get the list to sort by date, newest first, but can’t seem to get it to work that way. I’m using the shortcode [ESPRESSO_MY_EVENTS show_expired=true order_by=date(end_date) sort=DESC]. No matter what the sort= value it (ASC or DESC) it sorts oldest first. How can I switch it to display the most recent events first and go backwards?
Is there a way to limit the events that are displayed to the past 100 days?

Thanks!


Lorenzo Orlando Caum

  • Support Staff

April 14, 2014 at 7:02 pm

Hello,

Could you share the page that you found those order by parameters on for Espresso My Events?

It may not be working as I think those parameters apply to the the Event List shortcode:

https://eventespresso.com/wiki/shortcodes-template-variables/#my-events


Lorenzo


Trevis

April 14, 2014 at 7:08 pm

Now that I think about it, I may have just used those thinking they would apply to this shortcode as well, assuming it would be consistent across the plugins you offer.

If that’s not the case, how can I go about getting those to sort newest to oldest?

And how can I cap what’s displayed to the past 100 days?

Thanks,
Trevis


Trevis

April 14, 2014 at 7:23 pm

Not sure what happened but, it seems to be sorting the way I want it o now. But is there a way to cap the events that are displayed to those within the past 100 days?


Trevis

April 14, 2014 at 7:25 pm

I take that back, still not sorting properly. I think when I manually sorted it by date, my browser remembered the preference. When I looked in another browser it was back to the other way. Sorry about that.


Dean

April 15, 2014 at 4:48 am

Hi,

The my events table cannot be sorted via shortcode parameters, but rather by clicking the table titles.

If you want the tables to be sorted first time, then you would need to edit the SQL query.

They_events_page.php file in the espresso-members plugin folder contains the code.

It’s a pluggable function, but I edited line 117 which reads

WHERE u.user_id = '%d' AND a.payment_status != 'Cancelled'",

to say

WHERE u.user_id = '%d' AND a.payment_status != 'Cancelled'
 ORDER BY e.start_date ASC",

I don’t recommend core edits so copying the function to your themes functions.php or to a custom plugin would be wise. If you are not comfortable editing PHP then you may need a developer to assist you.


Trevis

April 15, 2014 at 1:06 pm

That did the trick, thanks Dean! I had made a copy of the my_events_page.php and put it in with the other copied template files in the uploads folder so, I should be good there.

One more thing—is there a way to cap the events that are displayed to those within the past 100 days? This would be useful to my clients who will be using the feature to track their volunteer hours, which they do every three months or so.


Dean

April 17, 2014 at 3:48 am

I have NOT tested this, but you could try something like this

AND DATE_SUB(NOW(),INTERVAL 100 day) <= e.start_date

where you check if the event start date is within 100 days

http://wordpress.org/support/topic/get-posts-from-the-last-60-minutes-from-a-given-category?replies=14

Screenshot of code http://take.ms/DKYOx

As said, it is untested, so use at your own risk.


Trevis

April 17, 2014 at 8:26 am

Cool, I’ll give it a shot. Thanks Dean!

Viewing 8 reply threads

The support post ‘My Events Page sort and filter’ 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