Posted: July 19, 2023 at 4:15 am
Hello, I use a custom template to display events. At the moment this is displaying all *elapsed* alongside current events, which we don’t want. We just want to show forthcoming events. I’ve been looking for a way to hide these, and came across this code snippet that you’ve provided for other customers: This appears to at least partially work for me. Expired events are hidden from view, but the site now shows multiple links for each event, based on how many ticket-types the event has (i.e. it shows three links to the same event if that event has three tickets-types assigned to it). Would you be able to give a variation on the above snippet that will only show one link per event, regardless of how many tickets are assigned to it? Or could you suggest any other way of preventing elapsed events from showing across the site? (e.g. automatically unpublishing them?) Thanks for any help you can offer |
|
Hi there, The above behaviour isn’t expected from that snippet and I suspect this is linked to your custom template:
Which template for what output/endpoin? Can you add the template to a PasteBin and post a link here for me to view the code? |
|
This reply has been marked as private. | |
Hmm ok so yeah it’s from that ALM plugin. Event Espresso events are a custom post type hybrid, the event posts are within wp_posts, but everything else uses custom tables all tied together using the post ID. The easiest way I can think of doing this is using your second approach:
Thats going to return and array of Event ID’s for the above, does that work for you? |
|
Hi Tony, and thanks for the help – I really appreciate it. So I got the comma-separated list of ID’s working with the plugin shortcode… BUT… for some reason it still displays multiple entries for each event. I’ve updated the pastebin link with the code I’ve just added to the template. I’ll paste this in a private reply below. There’s a definite correlation between the amount of duplicate entries displayed, and the different ticket types for each event (i.e. an event with three ticket types available is shown three times) Is there any way of taking the number of ticket types out of the equation? Thanks again for any help you’re able to offer. |
|
This reply has been marked as private. | |
Sorry! A quick update to the above… I just realised that I had neglected to remove the original code snippet (from my first post) from functions.php. After I removed that, the comma-separated-list fix appears to work…! 🤞 Thanks again for your help with this – it’s much appreciated. |
|
Awesome, I’m glad yo found a solution 🙂 Any further questions just let us know. |
|
The support post ‘Hiding expired events from view’ 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.