Conditional display based on category

Home Forums Calendar Products Events Calendar PRO Conditional display based on category

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #722182
    dkinney
    Participant

    One the single event template, I need to display some code ONLY if the event is in a specific category, and I need to do this after the title, so it is before the loop. Is there a code example?

    #722464
    Josh
    Participant

    Hello Diane,

    Thanks for reaching out to us!

    You can add the code you need to the single event template by following the instructions within our Themer’s Guide. You can copy the “single-event.php” file into your child theme using the instructions from the guide ( would copy to  ‘wp-content/your-theme/tribe-events/single-event.php’) .

    Then, under the header there you could use the “has_term” WordPress conditional to check to see if this event is assigned to your desired category. If so, you could then display your desired content.

    Let me know if this helps.

    Thanks!

    #722497
    dkinney
    Participant

    This is EXACTLY what I have been trying with no success.
    <?
    if (has_term( ‘exhibits’, ‘event-categories’ ) ) {
    echo “It works”;
    };
    ?>

    #722550
    Josh
    Participant

    Hello Diane,

    Try using “tribe_events_cat” instead of “event-categories” for the taxonomy and see if that fixes the issue.

    Thanks!

    #863596
    Josh
    Participant

    Hello dkinney,

    It’s been a while since we’ve heard from you. We like to close tickets after they’ve been inactive for a while. If you have any further questions, please don’t hesitate to open a new ticket.

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Conditional display based on category’ is closed to new replies.