Hide Category from Main Calendar, but not Category Calendar

Home Forums Calendar Products Events Calendar PRO Hide Category from Main Calendar, but not Category Calendar

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1012052
    jwhite
    Participant

    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!

    #1012254
    Brian
    Keymaster

    Hi,

    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

    #1012424
    Mary Correia-Moreno
    Participant

    Hi,

    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!!

    #1012460
    Brian
    Keymaster

    Hi 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

    #1012787
    jwhite
    Participant

    Thank 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.

    #1012865
    Brian
    Keymaster

    Hi, try changing it to this with the quotes around each slug:

    array('agency-distribution','community-market','mobile-pantry'),

    #1013911
    jwhite
    Participant

    That worked. Thank you so much, Brian!

    #1014040
    Brian
    Keymaster

    Great 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

    #1284939
    Support Droid
    Keymaster

    Hey 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

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Hide Category from Main Calendar, but not Category Calendar’ is closed to new replies.