Home › Forums › Calendar Products › Events Calendar PRO › Using is_category
- This topic has 5 replies, 2 voices, and was last updated 10 years, 7 months ago by
Brian.
-
AuthorPosts
-
September 9, 2015 at 12:45 pm #1003437
Courtney
ParticipantI 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?
September 9, 2015 at 12:50 pm #1003442Courtney
ParticipantI 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?
September 10, 2015 at 8:53 am #1003746Brian
MemberHi,
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
September 10, 2015 at 10:25 am #1003791Courtney
ParticipantCan 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.
September 10, 2015 at 12:10 pm #1003835Courtney
ParticipantI 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!
September 10, 2015 at 1:12 pm #1003877Brian
MemberI 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!
-
AuthorPosts
- The topic ‘Using is_category’ is closed to new replies.
