Home › Forums › Calendar Products › Community Events › Related Events Are Not Related
- This topic has 6 replies, 3 voices, and was last updated 10 years ago by
Support Droid.
-
AuthorPosts
-
March 14, 2016 at 10:17 am #1088530
dcantato
ParticipantI was looking at the related events and realized they are not related at all to the event shown. I read through the documentation and it said it relies on tags and categories.
So I went in and added tags to a group of events. Loaded one up and it is still random.
Does related events default to category before tags? Can I change that?
All of my events for the moment are in the same category.
Also is it possible to do related events by location? That would seem like the most relatable events.
March 14, 2016 at 2:19 pm #1088790George
ParticipantHey @dcantato,
I’m sorry to hear that your “related events” results are sub-par. Tags and categories are weighed equally by the function that loads related events, but if you would like to change the function at all, you can indeed do this.
Modifying the function OR adding location-based relationships are both, unfortunately, code customizations. I say “unfortunately” because we cannot help with code customizations. Check out “product support” on this page for more information about that → http://theeventscalendar.com/terms
That being said, there are two filters you can use:
• tribe_related_posts_args
• tribe_get_related_postsThese are quite powerful on their own and I hope you find them useful. To learn more about these filters, and about the function that gets related posts in general, then head to this file in your plugin files for Events Calendar Pro:
events-calendar-pro/src/functions/template-tags/general.phpThe function to look for is called tribe_get_related_posts().
I hope this information helps. Best of luck with your customizing!
– George
March 22, 2016 at 11:04 am #1092512dcantato
ParticipantIf I took out the categories part of the if statement would it rely on the tags only?
if ( $tags ) { $args['tax_query'][] = array( 'taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $tags ); } if ( $categories ) { $args['tax_query'][] = array( 'taxonomy' => Tribe__Events__Main::TAXONOMY, 'field' => 'id', 'terms' => $categories, ); }March 22, 2016 at 6:56 pm #1092686George
ParticipantHey @dcantato,
That indeed may work—try it out on your site firsthand and see what happens!
We cannot help with customizations, @dcantato, so for any further code-related questions you will have to take the reins on tinkering, learning, and seeing what works.
Please read this page to learn more about the type of support we can provide → https://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/
Thank you,
George
PS
So while everything I wrote above is true, I still wanted to help you resolve this. You ask about removing categories by removing the OR statement; this unfortunately won’t quite do the job, and to hopefully save you time, I have just gone ahead and written a snippet for you. 😉 Please read it and try to see how it works, I hope you can learn from it!
To use the snippet, first remove all other custom coding you’ve done so far to try and achieve this.
Once that’s gone, add the following code to your theme’s functions.php file:
/**
* FORCE the "Related Events" section to only to look in tags for relationship.
*
* @link http://m.tri.be/192k
*/
add_filter( 'tribe_related_posts_args', 'tribe_force_tags_for_related_events' );function tribe_force_tags_for_related_events( $args ) {
if ( ! is_array( $args['tax_query'] ) )
return $args;foreach ( $args['tax_query'] as $key => $arg ) {
if ( ! empty( $args['tax_query'][ $key ]['taxonomy'] ) ) {if ( 'tribe_events_cat' === $args['tax_query'][ $key ]['taxonomy'] )
unset( $args['tax_query'][ $key ] );
}
}return $args;
}
That works well for me and should reduce the search for similar events to ONLY look for tags—not categories, no matter what.
Cheers
March 23, 2016 at 7:47 am #1092884dcantato
ParticipantI’ll give this a try soon, thanks for the added support!
March 23, 2016 at 9:42 am #1092950George
Participant🙂
April 7, 2016 at 9:35 am #1099623Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Related Events Are Not Related’ is closed to new replies.
