Home › Forums › Calendar Products › Events Calendar PRO › Show 4 Related Events
- This topic has 5 replies, 2 voices, and was last updated 9 years, 10 months ago by Casey.
-
AuthorPosts
-
June 2, 2014 at 10:03 am #198832JonathanParticipant
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!
June 2, 2014 at 10:10 am #198849JonathanParticipantWe have now tried tribe_get_related_posts($count = 4, $post = false); and that still does not seem to be working.
June 3, 2014 at 7:27 am #201119CaseyParticipantangoddard,
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-
June 3, 2014 at 8:48 am #201304JonathanParticipantHi 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.
June 3, 2014 at 8:53 am #201320JonathanParticipantCasey,
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!June 3, 2014 at 12:46 pm #201846CaseyParticipantAwesome! 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 -
AuthorPosts
- The topic ‘Show 4 Related Events’ is closed to new replies.