If-Then based on Event Category Function?

Home Forums Calendar Products Events Calendar PRO If-Then based on Event Category Function?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #32593
    Steph
    Participant

    Hello,

    I am on the web team for informedmedicaldecisions.org. We are adding an area to the site that uses different template parts for a specific category of events. We have also purchased Events Calendar Pro, as well as the Eventbrite Add-on.

    The problem:
    Running a nice function if/then statement based on an event’s inclusion in a category.

    We do have the following working properly and tested:
    . events calendar settings theme: Default Events Theme
    . events folder in our theme with customized files named:
    .. ecp-page-template.php
    .. ecp-single-template.php
    . special template parts do work in these ecp files when the if/then statement is not involved.
    Here is a link to the messy solution I created: http://pastebin.com/w1ry6HUm

    It seems to me that there must be a better way than writing my own function, but I have had no luck finding an appropriate function in your documentation.

    Obviously, coding is not my main occupation.

    Any help is welcome. This solution seems like it will not stand up to updates.

    Thanks, Rosemary

    #32601
    Steph
    Participant
    #32602
    Steph
    Participant

    Ok, solved that one then by having my klugy function (show above) called in ecp-single-template.php and the tribe_meta_event_category_name function called in ecp-page-template.php.
    Would still love to know if there is a better solution than my own function…

    #32618
    Barry
    Member

    Possibly by using the tribe_event_in_category() function, which accepts a category slug and optionally the event ID (otherwise it just assumes you are interested in the current event).

    if (tribe_event_in_category('my-category-slug')) { /* Do something */ }

    #32679
    Steph
    Participant

    Thanks! This is the kind of think I’ve been looking for!

    #32683
    Barry
    Member

    Great!

    #978615
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘If-Then based on Event Category Function?’ is closed to new replies.