Related events aren't filtering by category

Home Forums Calendar Products Events Calendar PRO Related events aren't filtering by category

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1008777
    Nicholas
    Participant

    Hello!

    I have a category filled with a number of events. When viewing a single event in this category, there is a section with “related events”, however the events listed here are not in the same category or related in any way that I can tell.

    #1009073
    Brian
    Keymaster

    Hi,

    Sorry for the issues you are having. I can help troubleshoot this with you.

    The related events use both tags and categories to get events.

    Are you using tags as well as categories?

    Let me know and we can go from here.

    Thanks

    #1009075
    Nicholas
    Participant

    No tags or categories used on the events that are appearing as “related events”

    #1009136
    Brian
    Keymaster

    Hi,

    Thanks for the information.

    There maybe a conflict then creating this.

    Can you please follow our testing for conflicts guide:

    https://theeventscalendar.com/knowledgebase/testing-for-conflicts/

    And see if that can narrow down the cause of this or at least narrow down it is an issue with the coding.

    Let me know what you find out.

    Thanks

    #1009493
    Nicholas
    Participant

    Thank you! Yes, I did find a theme conflict and the source was a bit of code I was using in my functions file. (see below)

    The purpose of this function was to remove events in the category “tech” from the main events page. My goal is to have a main events page that functions normally but excludes all events in the “tech” category. Then I want this separate page that includes only tech related events.

    Is there another way to accomplish this? Or is there away to keep the function I have but fix it so that the related posts feature works correctly on single tech events??

    // Removes categories "tech" from list and month views
    add_action( 'pre_get_posts', 'exclude_events_category' );
    function exclude_events_category( $query ) {
    if ( $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('tech'),
    			'operator' => 'NOT IN'
    		)
    		)
    	);
    }
    return $query;
    }
    #1009651
    Brian
    Keymaster

    Hi,

    I am limited in supporting customizations like this, but try adding this to the snippet to see if this stops it from running:

    Before this:

    $query->query_vars['eventDisplay'] == 'list'

    Add this

    ! is_singular( 'tribe_events' ) &&

    Not sure if that will work, but it is worth a shot.

    Let me know if that helps.

    THanks

    #1009749
    Nicholas
    Participant

    That did it! Thank you!

    #1009778
    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Related events aren't filtering by category’ is closed to new replies.