Show 4 Related Events

Home Forums Calendar Products Events Calendar PRO Show 4 Related Events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #198832
    Jonathan
    Participant

    Hey There!

    We are currently using the tribe_get_related_posts(); function to loop through related events, is there a way to have this function return 4 related events as opposed to the defaulted 3?

    Thanks!

    #198849
    Jonathan
    Participant

    We have now tried tribe_get_related_posts($count = 4, $post = false); and that still does not seem to be working.

    #201119
    Casey
    Participant

    angoddard,
    Thanks for getting in touch! Where exactly are you calling this function from? If you’re calling it outside of the WordPress loop, then you’ll also need to pass the post ID of the Event that you want to display related events for. If you’re calling it inside the loop, then you should just call it like this:

    
    //Called from inside the WordPress loop
    $related_posts = tribe_get_related_posts( 4 );
    
    //Called from outside the WordPress loop
    $post_id = 245; // some integer
    $related_posts = tribe_get_related_posts( 4, $post_id );
    

    Then you’d have to loop through the items in the $related_posts variable and display them. Take a look at ‘views/pro/related-events.php’ for a good example on how to do this, and then let me know if you have further questions. Thanks! 🙂

    -Casey-

    #201304
    Jonathan
    Participant

    Hi Casey,

    Thanks for your reply. We are calling it outside of the loop, and I have updated the function by passing through the event id:

    <?php $related_posts = tribe_get_related_posts(4, $event_id); ?>

    Yet, it is still returning an array of 3 events as opposed to 4. I have double checked that the event id is accurate.

    #201320
    Jonathan
    Participant

    Casey,
    The function you gave me works, I did not have 4 live events in my testing environment, which is the reason why I was not receiving an array of 4 events. Thanks again for your help!

    #201846
    Casey
    Participant

    Awesome! Thanks for confirming that this got you sorted. Since it looks like you’re all set, I’m going to mark this thread “Answered” and close it out.

    By the way, if you have a minute or two, we would love it if you’d write a few words for us here: http://m.tri.be/jw

    Thanks in advance. 🙂

    Cheers,
    Casey

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Show 4 Related Events’ is closed to new replies.