Checking for a category

This topic contains 2 replies, has 2 voices, and was last updated by  Adam Abrams 2 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41255

    Hi! I want to check if an event is in a particular category – in this case, “VJFF”, which is category #22. But I can’t get it to work…

    I’m currently trying this, in single-event.php :

    if (is_tax( 'event-category', 22) ) {
    echo 'stuff';
    }

    But I’m clearly guessing (and wrongly) as to how I specify it… as it is not echoing my custom “stuff” even when the post is in the VJFF category. Can you advise? Thanks!

    Adam Abrams
    #41363

    Hi Adam,

    The is_* functions refer to the page. Instead you want to use has_term()

    has_term( "VJFF", "event-category").
    

    Depending on context you may have to pass in the event object as the third argument.

    Stephen Harris
    #41386

    Thanks for this Stephen! I’ll let you know if I run into any further issues.

    Adam Abrams
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.