Posted: January 22, 2020 at 1:28 pm
|
Hi, I’m trying to remove some events from displaying on the upcoming events widget.
Currently, this works great to remove the events that match the slug, but ideally, we would remove all events in a category. How do I rewrite that WHERE definition to exclude all events within a category? Thanks! |
Hi there, I highly recommend taking a look at our model documentation, available here: To alter the query to return events not in a specific term, you can use the slug like so:
Or the term_id if preferred:
20 being an example ID, you’d use your own.
|
|
|
Thank you for the help! I did review the documentation, but it’s not clear on how to access taxonomy attributes. I tried both code examples, but no luck. The events are not being excluded.
I also tried: Screenshot showing the category ID: https://drive.google.com/file/d/11PKOADxtantA1MedIT_RUMCxB9-pMSlX/view Any idea why it’s not excluding events with that category from the query? Thanks! |
Hmm, strange. Do you have a category set on the widget? (Within the widget options, not through code) |
|
|
Nope, it’s set to display all. https://drive.google.com/file/d/14S5Pyl45E6ArGwbh5ekqLUZxnv8-Ny8_/view?usp=drivesdk Any other way of excluding one taxonomy term? |
No. What happens when you also set the taxonomy?
If that doesn’t work I’ll need to view the widget and an event set on the above term. |
|
|
I think that did it! Thank you! |
Hmm, ok. I’m glad that’s fixed it, but that means all of your events are in at least 1 category, correct? If so, is that always the case? (If it is it’s fine as is). |
|
The support post ‘Exclude Event Categories from Upcoming Events Widget’ 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.