has_category() not working – alternatives?

Home Forums Calendar Products Events Calendar PRO has_category() not working – alternatives?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #139274
    Adrian Cumpanasu
    Participant

    Hi!
    I was trying to check if the event has a category, but it returns always false.
    What can I use instead?

    P.S. I used this code: http://pastebin.com/GxNAQRbt in case there isn’t a similar function inside the plugin

    thanks!

    #139537
    Casey
    Participant

    advmaremma,
    Thanks for getting in touch! Since the ‘tribe_events’ custom post type implements a custom taxonomy for our Event Categories, you’ll need to use the has_term method instead. Something like this should do the trick:


    if( has_term( 'category-slug-to-check', 'tribe_events_cat' ) ) {
    // do something
    }

    Give that a shot and let me know if it does the trick for you. Thanks! 🙂

    -Casey-

    #140152
    Adrian Cumpanasu
    Participant

    working great! thanks!

    #140909
    Casey
    Participant

    Great! Thanks for confirming that this got you sorted. Since it looks like you’re all set, I’m going to mark this thread “Answered” and close it out.

    By the way, if you have a minute or two, we would love it if you’d write a few words for us here: http://wordpress.org/support/view/plugin-reviews/the-events-calendar?filter=5

    Thanks in advance. 🙂

    Cheers,
    Casey

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘has_category() not working – alternatives?’ is closed to new replies.