Home › Forums › Calendar Products › Events Calendar PRO › Hide Category from Main Calendar, but not Category Calendar
- This topic has 9 replies, 3 voices, and was last updated 6 years, 11 months ago by jwhite.
-
AuthorPosts
-
October 6, 2015 at 2:10 pm #1012052jwhiteParticipant
Hello,
I’m using Events Calendar Pro and have a question. I want to create events in a category, but not have these events appear on the main calendar, only have them appear on the category calendar.See: http://192.138.20.76/~foodsha/ and http://192.138.20.76/~foodsha/events/ lists the event “Community Market Distribution – Camarillo” which is in the “community-market” category. I only want this event (and all events I create in this specific category) to appear on this calendar: http://192.138.20.76/~foodsha/events/category/community-market/ – not on the /events/ or any other calendar/listing.
I have found the coding for functions.php that hides the category from calendar view, but it also hides it from the category’s calendar. The same thing happens when I check “Hide From Event Listings” when creating the event.
Is there a way to accomplish what I need? Thank you in advance!
October 7, 2015 at 6:40 am #1012254BrianKeymasterHi,
Thanks for using our plugins. I can help out here.
I think I can help you add a conditional to fix this.
If you add this in your conditional check:
&& !is_tax()
It should prevent the snippet from running on the category views.
If you are unsure where to put it, please post a link to the snippet or copy it into a reply.
Let me know what you find out.
Thanks
October 7, 2015 at 11:52 am #1012424Mary Correia-MorenoParticipantHi,
I’m in need of this same fix. We have 6 different event categories [Networking, Policy, International, Professional Development, Signature, and Community]. On the Main Calendar I need to hide the community events from being displayed from the main calendar view and the main list view.
Underneath the main calendar I have a section called community events which displays the latest three community events using this which works great:
<ul class="list-community-events"> <?php $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => 3, 'tag_ID' => '19' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; ?> </ul>
After that i have a link to separate page that displays just the community events:
/events/category/community/list/I want all of this to continue to work exactly as i have setup but just NEED the community to not display on the default main calendar month and list view.
any help is GREATLY appreciated!! thanks!!
- This reply was modified 8 years, 6 months ago by Mary Correia-Moreno.
October 7, 2015 at 1:14 pm #1012460BrianKeymasterHi William,
Thanks for posting here. I can certainly help you here, but we can help you better if you create your own topic in the forum, where we can interact with you one on one. Also, we encourage you to post on your own topic because every time we post it will email the author of the topic.
Having said that this snippet might work for both of you:
https://gist.github.com/jesseeproductions/a467b28a8b8010d4015b
Add that coding to your theme’s functions.php and then replace the slug ‘tech’ with the slug of the event category you are trying to remove from the Month and List Views.
Thanks
October 8, 2015 at 11:41 am #1012787jwhiteParticipantThank you for the reply, Brian. I added the code that you linked to here: https://gist.github.com/jesseeproductions/a467b28a8b8010d4015b on to my theme’s functions.php – it did not hide the categories I’m looking to hide. Here is what I added:
// Removes categories "tech" from list and month views add_action( 'pre_get_posts', 'exclude_events_category' ); function exclude_events_category( $query ) { if ( ! is_singular( 'tribe_events' ) && $query->query_vars['eventDisplay'] == 'list' && !is_tax(TribeEvents::TAXONOMY) || $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'tax_query', array( array( 'taxonomy' => TribeEvents::TAXONOMY, 'field' => 'slug', 'terms' => array('agency-distribution,community-market,mobile-pantry'), 'operator' => 'NOT IN' ) ) ); } return $query; }
Before I created this post, I used the code here: https://gist.github.com/theeventscalendar/c9580839c3a76778d583
on my functions.php file. It did hide the events in the category from the main calendar, but it also hid the events from their own category calendar – which is where I want them to appear.October 8, 2015 at 2:30 pm #1012865BrianKeymasterHi, try changing it to this with the quotes around each slug:
array('agency-distribution','community-market','mobile-pantry'),
October 12, 2015 at 4:32 pm #1013911jwhiteParticipantThat worked. Thank you so much, Brian!
October 13, 2015 at 6:31 am #1014040BrianKeymasterGreat glad it helps.
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks
May 17, 2017 at 9:36 am #1284939Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Hide Category from Main Calendar, but not Category Calendar’ is closed to new replies.