Changing the words 'events' and links based on category

Home Forums Calendar Products Events Calendar PRO Changing the words 'events' and links based on category

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1172201
    Jeff Schneider
    Participant

    I 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

    #1172560
    George
    Participant

    Hey 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.php

    Anywhere 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,
    George

    #1172611
    Jeff Schneider
    Participant

    Thanks George,

    I found that a conditional like this got what I needed in the override.

    if ($instance[‘category’]==’tours’) {

    #1172618
    Jeff Schneider
    Participant

    And for a single event, this worked

    if (tribe_event_in_category(‘tours’)) {

    }

    #1173000
    George
    Participant

    Excellent—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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Changing the words 'events' and links based on category’ is closed to new replies.