Posted: June 8, 2015 at 3:55 pm
|
As our clients classes sell out we want to hide them or move them below the available events so visitors won’t have to scroll down each page. I couldn’t find this in the wiki? |
Hi Bob, There’s some example code from Github that will remove any upcoming events that no longer have tickets for sale from the event list. https://eventespresso.com/wiki/useful-php-code-snippets/#no-tickets-no-event-list Please note that the code will affect all of the event lists. If you intend on only hiding the sold out events from your pages with shortcodes, you can wrap the code in a conditional check for those pages. |
|
|
To clarify you are saying this link to GitHub: I’m not sure expired tickets is what we want, this page shows a number of sold out events that haven’t started yet and people have to scroll down to find the next available event: http://streetsmartsdriversed.com/iowa/marion/indian-creek-ind-classes/ |
Hi Bob, It’s up to you if you want to remove the check for expired events from the example code. You can add a check for a sold out event condition by adding the following to the end of the SQL statement in the first function of the example code:
|
|
|
Thanks Josh but I’m not that good with code, I can copy paste 🙂 Which line or change do I make to the Github code? |
On line 15, where the first function has this:
You change it to this:
|
|
|
I tried that but it removes all events from the page. |
It may help if you can copy and paste the code that ended up in your functions file in a gist or pastebin and link here so we can make sure there were not any errors in the copy and pasting. This is because I checked the code on a site before I shared it with you and it only removed the sold out events. Aside from that, it may be quicker if this gets worked out with a priority support token since it’s a customization. |
|
|
Josh I’m using the code you referenced at GitHub
If you want to send me your entire code, and if it’s working on your site, I’ll use all the code vs a line here and there. The above is the standard code without the edits we’ve been trying to make. I’m surprised I’m the first person to ask about hiding sold out events? Thanks for your help, we aren’t in any rush. |
Hi Bob, Posting the code here doesn’t really help because our forum software is not designed to handle large blocks of code like this. There could be a single quote replaced by a curly quote, which would throw an error, but since you didn’t post to a pastebin or gist I can’t really tell. Are you using a code editor to edit the file? Here’s a link to a gist that has the modified code. If you’re editing the PHP files with something like text edit, you might run into trouble with quotes getting converted to curly quotes. It may help to have a PHP developer look things over if you’re not sure. |
|
|
Josh, I’m using Coda to edit the functions.php file Thanks for posting the code but when I apply it same results, it blocks all classes. Unfortunately I can’t leave it to have you view as they are taking registrations daily… I can however setup a staging site in WPEngine and test there, then I’ll send you a link.. later today or tomorrow. |
The support post ‘EE4 Hide sold out events from [ESPRESSO_EVENTS category_slug=""] page’ 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.