Home › Forums › Calendar Products › Events Calendar PRO › Related events aren't filtering by category
- This topic has 7 replies, 2 voices, and was last updated 8 years, 7 months ago by Brian.
-
AuthorPosts
-
September 25, 2015 at 11:57 am #1008777NicholasParticipant
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.
September 27, 2015 at 4:59 pm #1009073BrianKeymasterHi,
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
September 27, 2015 at 5:31 pm #1009075NicholasParticipantNo tags or categories used on the events that are appearing as “related events”
September 28, 2015 at 6:06 am #1009136BrianKeymasterHi,
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
September 28, 2015 at 7:03 pm #1009493NicholasParticipantThank 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; }
September 29, 2015 at 7:25 am #1009651BrianKeymasterHi,
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
September 29, 2015 at 9:56 am #1009749NicholasParticipantThat did it! Thank you!
September 29, 2015 at 11:23 am #1009778BrianKeymasterGreat 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
-
AuthorPosts
- The topic ‘Related events aren't filtering by category’ is closed to new replies.