Conditional based on Event Category

Home Forums Calendar Products Community Events Conditional based on Event Category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1067330
    Tim
    Participant

    Howdy,
    I am trying to figure out how to make a conditional based on an event category, “workshops” when I am on the category archive page for “workshops” and I can’t seem to figure it out or find functions that already exist for it. I know the following function doesn’t work, but something like this:

    
    <?php if (is_tax( 'workshops' )) {
    echo 'It works';
    }
    else {
    echo 'It doesn't work';
    }
    ?>
    
    • This topic was modified 10 years, 2 months ago by Tim.
    #1067760
    Tim
    Participant

    Nevermind, I figured it out! Woo hoo!

    This is what I used in case anyone wants the goods…

    
     <?php 
    $cat_name = single_cat_title( '', false );
    if ($cat_name == "workshops") {
    	echo "Workshop Category Code!";
    }
    elseif ($cat_name == "seminars") {
    	echo "Seminar Category Code!";
    }
    ?>
    
    #1067762
    Cliff
    Member

    Hi.

    Using is_tax() like you did is appropriate if you have an Event Category with the slug ‘workshops’

    The issue might be that your code works just fine but you’re not implementing it in the right way.

    Did you use add_action() or add_filter() to implement it, for example, in your child theme’s functions.php file?

    If you end up not being able to figure it out, please provide links and/or screenshots of what you’re wanting and where you want it and I may be able to help you.

    Thanks!

    #1067763
    Cliff
    Member

    Oh, I saw you updated just before I did.

    I’m glad you figured things out. Thanks for letting us know and for sharing your code so others may benefit.

    Have a great day!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Conditional based on Event Category’ is closed to new replies.