• Resolved juppi91

    (@juppi91)


    Hey there,

    I am using the events calendar for quite a time and would like to change the look of the single event page for a certain category.
    I’ve been trying several possibilities and reading different forum posts to find out the right conditional. In one post I read that

    <?php if (has_term( 'my_category', 'tribe_event_category')); ?>
      <p>It works!</p>
    <?php endif; ?>

    should work. In fact it does not on my site. I have tried the same code with “term_exists” and “is_object_in_taxonomy” instead of “has_term” and all versions with “tribe_event_cat” as well.
    Can anyone give me a hint on the correct conditional that would do the trick?
    Thnaks a lot for your help,
    Felix

    https://www.ads-software.com/plugins/the-events-calendar/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Felix,

    Thanks for reaching out! I think you are using the wrong taxonomy name, it should be tribe_events_cat. So this:


    <?php if (has_term( 'my_category', 'tribe_events_cat')); ?>
    <p>It works!</p>
    <?php endif; ?>

    Also you should check the context in which this code is run, you might need to pass the event (post) id as the third parameter.

    Best,
    Nico

    Thread Starter juppi91

    (@juppi91)

    Hey Nico,

    thanks a lot this does the trick, with one change: above is a semicolon in the if-term (a typing mistake in my request ?? but it has to be a colon. So the working code is

    <?php if (has_term( 'my_category', 'tribe_events_cat')): ?>
      <p>It works!</p>
    <?php endif; ?>

    Thanks for helping,
    Felix

    Thanks for the update, Felix!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional to chang look for a specific category (single event page)’ is closed to new replies.