Support

Home Forums Event Espresso Premium Display expired events on Event Category pages but not on main Events archive

Display expired events on Event Category pages but not on main Events archive

Posted: May 13, 2017 at 1:41 pm


Jerry

May 13, 2017 at 1:41 pm

Can you suggest a function or filter or something that I can use to display expired events on Event Category pages (e.g. /event-category/winter-2017/ but NOT on the main Events archive page (/events/). Thanks so much!


Seth Shoultes

  • Support Staff

May 15, 2017 at 10:31 am

Hi Brenda,

You might try using an Event Espresso shortcode on a page instead. Here’s the shortcode I would use on a page:

[ESPRESSO_EVENTS category_slug=winter-2017 show_expired=true]

Hope that helps. Please let us know if you have further questions.


Jerry

May 15, 2017 at 12:07 pm

Hmm, thanks for the suggestion, but I don’t think that’s optimal for my situation. I’m setting this up for an end user to take over, and this would mean an extra complication of making a page for every new category on this dynamic website.

I really hardly even need the /events/ page, except that EE4 presents a link to that archive in certain situations:

Nothing in your Event Queue
You need to select at least one event before you can proceed with the registration process.

Is there some way I can change that select at least one event link?

Thanks!


Tony

  • Support Staff

May 15, 2017 at 6:30 pm

The text output used there is passed through a filter so you can change it if needed, the filter is:

FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg

So something like this:

https://gist.github.com/Pebblo/4aa2463d2781170f383710ce519ca082

Then just edit the link used within the function, it currently uses get_post_type_archive_link('espresso_events') to build the link.


Josh

  • Support Staff

May 15, 2017 at 6:42 pm

Hi Brenda,

Here’s an example that shows how to use the pre_get_posts hook to remove the filters that filter out the expired events on the event category archives:

https://gist.github.com/joshfeck/868ba9f309019d1b9d8b2187d56ad7bb

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


Jerry

May 16, 2017 at 10:10 am

Ooh, both excellent suggestions! Josh, I set Display Expired Events to NO globally, then used your code to negate that for Category pages. Works nicely!

On on /events/, I’d also like to hide events where tickets are have ended — is there a way to filter out those?


Josh

  • Support Staff

May 16, 2017 at 11:33 am

You can use this to filter those out:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/templates/de_ee_filter_events_out_with_expired_tickets.php

You can remove this part:

&& ! $wp_query->is_espresso_event_taxonomy

and add a conditional for $wp_query->is_espresso_event_taxonomy so it doesn’t filter out events with expired tickets on the taxonomy archives.


Jerry

May 16, 2017 at 2:20 pm

Thanks, Josh, I will give that a shot!

The support post ‘Display expired events on Event Category pages but not on main Events archive’ 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