Home › Forums › Calendar Products › Events Calendar PRO › Trying to get "next upcoming event" but it's pulling wrong event…
- This topic has 14 replies, 5 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
January 19, 2012 at 1:46 pm #13653
Trevor
MemberI have a section on my site where I’m trying to pull just the next upcoming event, but it’s like it’s skipping a bunch of events and pulling one from March.
You can see it here on the main page: http://harvestpensacola.com right where it says “CALENDAR”. And then on the events page, there are obviously other events that it’s not pulling. http://www.harvestpensacola.com/events/
Here is code: http://pastebin.com/2HmVkTum
January 20, 2012 at 4:50 pm #13706Trevor
MemberAnyone?
January 23, 2012 at 11:13 am #13875Trevor
MemberAny news yet? I really need to get this fixed quickly.
January 23, 2012 at 11:23 am #13881Rob
MemberHey Trevor. Should have a response for you today. Apologies for the delay thus far, we generally don’t get on the forums over the weekends.
January 23, 2012 at 4:36 pm #13909Trevor
MemberThis guys seems to have a similar issue: http://wordpress.org/support/topic/plugin-the-events-calendar-the-next-three-events-in-the-widget?replies=3
Could it be that there’s no sort by for the tribe_get_events() function that I’m using?
January 23, 2012 at 9:16 pm #13918Jonah
ParticipantHi Trevor, the code you posted works fine for me. It’s pulling in my closest upcoming event on my local test site even when I have plenty of events after it.
I wonder if there’s some conflict with another plugin going or some script in your theme? Have you tried disabling some plugins to see if this fixes it? The site you posted loads very slow for me in Chrome so I wonder if this is related to the issue.
Another thing you could try is to just use WP_Query() and pass in tribe_events as the post type…
I hope that helps,
JonahJanuary 23, 2012 at 9:36 pm #13922Trevor
MemberHi Jonah,
Okay I will try using get_posts() to pull in the posts… how do I set the date to be after a certain date (or upcoming)?
January 23, 2012 at 9:46 pm #13925Trevor
MemberOkay Jonah, it’s definitely not a conflict… it’s something with the fact that the next event is a recurring event. It pulls the next events just fine if it’s just a regular, one-off event, but if it is a recurring event, it pulls the event, but the DATE is incorrect…
See here: http://www.harvestpensacola.com/
The event is listed as “Growth Track 401 – Dec 23”.When if you look here: http://www.harvestpensacola.com/events/upcoming/
The event is correct, but the date should be Jan 29.It’s like it’s pulling the wrong occurrance of the recurring event.
January 23, 2012 at 10:03 pm #13930Trevor
MemberOkay, I fixed it. In case others run into the same issue, I’ll post the solution.
Basically, recurring event occurrences have the same post ID, so if you pass an ID into functions like tribe_get_start_date() outside of the loop, you’ll get an unexpected result.
It works now if I set global $post, and then wp_reset_query() afterward, like so:
http://pastebin.com/BsYkidsSNot sure if this is expected behavior, but it works now.
January 24, 2012 at 11:13 am #13979Rob
MemberThanks for the heads up, Trevor – glad to hear you got this figured out. Let me see if Jonah or anyone else on the team has a suggestion re: how we can workaround the post ID issue in the official code. That way if a fix is possible, we can get it in for 2.1 or a subsequent release.
January 24, 2012 at 4:54 pm #14044Joey Kudish
MemberHi Trevor,
I’m a developer on the team here. As best as I can tell the function is working as intended and I don’t believe that what you’re doing is a hack or workaround, that’s how the function is intended to be used. Am I missing something?
January 25, 2012 at 9:54 am #14101Trevor
MemberYes I see that in the example functions you always declare global $post; and use setup_postdata(). I guess I didn’t realize that this was a requirement for the functions to work properly. Maybe make a note in the knowledge base that mentions they must be used with the global $post variable?
January 25, 2012 at 11:36 am #14113Joey Kudish
MemberHey Trevor,
Thanks for the suggestion, I’ll pass that along to Rob so that he can update the docs.
Cheers
January 26, 2012 at 7:40 am #14177Rob
MemberThanks guys! Just a heads up that this has been updated per Trevor’s note.
July 3, 2015 at 5:00 pm #975412Support 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 ‘Trying to get "next upcoming event" but it's pulling wrong event…’ is closed to new replies.
