Home › Forums › Calendar Products › Events Calendar PRO › Changing the words 'events' and links based on category
- This topic has 5 replies, 3 voices, and was last updated 9 years, 6 months ago by
Jeff Schneider.
-
AuthorPosts
-
October 4, 2016 at 5:18 am #1172201
Jeff Schneider
ParticipantI found this link, which is helpful, but I want to be able to change the word events to different words based on the category.
For instance we have “tours” and “services” as categories so I want to the wording to change dynamically based on the category. When there are no events to display in the list widget for tours, I want it to say “There are no upcoming Tours at this time”.
Also on the single event page, there’s a link to View All Events, using the tribe_get_events_link function. In my override, how do I change it to link just to tours (if the event’s category is ‘Tours’)?
I tried something like this but didn’t get me far
Thank you
October 4, 2016 at 10:18 pm #1172560George
ParticipantHey Jeff,
Thanks for reaching out.
We unfortunately cannot assist with coding.
Regardless of that policy, it’s also unfortunately true that pulling off the customizations you want here is a bit complex.
The best thing I can recommend—for both customizations you mentioned—is to get familiar with the function tribe_get_event_categories().
You can find this function here:
/the-events-calendar/src/functions/template-tags/general.phpAnywhere you want to add category links, or get category titles, you can use this function to get a list of the categories for the currently-viewed event. From there, you can tinker with code and explore material on the official WordPress Codex about custom taxonomies to learn about getting URLs, names, IDs, and other attributes of custom taxonomies (like Event Categories).
This function, for example, would let you get the URL for an Event Category: https://developer.wordpress.org/reference/functions/get_term_link/
When it comes to using this code in custom events templates, check out our official Themer’s Guide here → https://theeventscalendar.com/knowledgebase/themers-guide/
I hope this information helps you get started with your customizing!
Sincerely,
GeorgeOctober 5, 2016 at 2:58 am #1172611Jeff Schneider
ParticipantThanks George,
I found that a conditional like this got what I needed in the override.
if ($instance[‘category’]==’tours’) {
…October 5, 2016 at 3:52 am #1172618Jeff Schneider
ParticipantAnd for a single event, this worked
if (tribe_event_in_category(‘tours’)) {
}
October 5, 2016 at 5:44 pm #1173000George
ParticipantExcellent—I’m sorry I didn’t think of mentioning the tribe_event_in_category function!
Best of luck with your custom coding. Be sure to make backups of all your code 😀
— George
-
AuthorPosts
- The topic ‘Changing the words 'events' and links based on category’ is closed to new replies.
