Using is_category

Home Forums Calendar Products Events Calendar PRO Using is_category

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1003437
    Courtney
    Participant

    I want to add a dropdown on my main events page to allow people to select from a dropdown some of the main categories. I found this code and was going work with it, but it’s not working.

    		if (is_category()) {
    			$cat = get_query_var('cat');
    			$yourcat = get_category ($cat);
    			echo 'the slug is '. $yourcat->slug;
    		}

    Does is_category() work on MT Events?

    #1003442
    Courtney
    Participant

    I figured there might be a MT way to do this and I just found this: https://theeventscalendar.com/function/tribe_is_event_category/

    However, it’s still not working. I’m wondering if it’s where it’s being placed. I’m in the pro views, in map > content. So it’s right after the <div id=”tribe-events-content” class=”tribe-events-list tribe-events-map”> tag. Do you think it needs to be within a loop or something?

    #1003746
    Brian
    Member

    Hi,

    Thanks for using our plugins.

    I can try to help out, but I am limited in supporting customization.

    is_category is just if you are on a category archive page so I do not think it will work.

    https://codex.wordpress.org/Function_Reference/is_category

    The Events Calendar Category is a custom taxonomy registered as:

    tribe_events_cat

    You might be able to use is_tax() instead to get what you are looking for.

    https://codex.wordpress.org/Function_Reference/is_tax

    Cheers

    #1003791
    Courtney
    Participant

    Can you clarify if a page like http://www.mysite.com/events/category/kickoff/ is considered a category archive page? That’s the type of page I’m trying to get this working on. It’s just also using the map content view for display.

    In the meantime, I’ll look into is_tax.

    #1003835
    Courtney
    Participant

    I figured it out by removing my custom view files one by one… turns out that an edit I’d made the default template was causing the problem. It’s resolved now. Thanks for the is_tax info, though. In my dropdown I ended up being able to use this:

    <?php if(tribe_is_event_category() && is_tax('tribe_events_cat','kickoff')): ?>selected="selected"<?php endif; ?>

    I’ll close this one out. Thanks!

    #1003877
    Brian
    Member

    I am glad to see you were able to figure it out.

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new ticket.

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Using is_category’ is closed to new replies.