Suggested change to tribe_get_related_posts() function

Home Forums Calendar Products Events Calendar PRO Suggested change to tribe_get_related_posts() function

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1222384
    Scott Anderson
    Participant

    I have a client who was frustrated that the Related Events list on their site was randomly showing events that are several months into the future, rather than showing events that are coming up in the next few days or weeks.

    In troubleshooting the issue, I found the tribe_get_related_posts() function offers a filter to override the default arguments, and I was able to get what I needed with the following modification:

    add_filter('tribe_related_posts_args', function($args) {
    	$args['meta_key'] = '_EventStartDate';
    	$args['orderby'] = 'meta_value';
    	return $args;
    });

    I would like to suggest that these should be the default arguments for this function. It doesn’t make a lot of sense to me as the developer, nor to my clients as site owners/users, to have random events in the distant future showing up in the results.

    #1223057
    Andras
    Keymaster

    Hello Scott,

    Thanks for getting in touch and for sharing your solution for this issue!

    This is awesome and it’s much appreciated!

    It makes a lot of sense and I will definitely forward this idea to our developers for consideration.

    Cheers,
    Andras

    #1223068
    Scott Anderson
    Participant

    Thanks!

    #1541389
    Victor
    Member

    Hi Scott!

    Just wanted to share with you that a new release of our plugins is out, including an improvement for the related events.

    Now, related events are ordered by the start date so they are displayed when they’re close to the date of the event that is actually being viewed

    Find out more about this release → https://theeventscalendar.com/maintenance-release-for-the-week-of-27-may-2018/

    Please update the plugins and see if the fix works for your site. Don’t hesitate to open a new topic if anything comes up.

    Best,
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Suggested change to tribe_get_related_posts() function’ is closed to new replies.