Home › Forums › Calendar Products › Events Calendar PRO › tribe_get_events returns posts when it should not
- This topic has 7 replies, 3 voices, and was last updated 7 years, 5 months ago by Josh.
-
AuthorPosts
-
October 20, 2016 at 2:04 pm #1180119Greg PerhamParticipant
I have a recurring event tagged “featured” starting 2016-07-08 and ending on 2016-08-26. Today is 2016-10-20, and I have no other events with that tag. Nevertheless, this returns the first two events from 7/8 and 7/15:
tribe_get_events( array(
'eventDisplay' => 'list',
'posts_per_page' => 2,
'tag' => 'featured',
'start_date' => date( 'Y-m-d' )
) );tribe_get_events should return nothing in this scenario.
October 21, 2016 at 1:45 pm #1180936JoshParticipantHey Greg,
Thanks for reaching out to us!
As a first test here, can you try changing the “date( ‘Y-m-d’ )” to “<span class=”pl-c1″>date</span>(<span class=”pl-s”><span class=”pl-pds”>'</span>Y-m-d<span class=”pl-pds”>'</span></span>)<span class=”pl-k”>.</span><span class=”pl-s”><span class=”pl-pds”>'</span> 00:00:00<span class=”pl-pds”>'” to see if that helps here. </span></span>
Alternatively, you could try using a meta_query there using the following options:
'key' => '_EventStartDate', 'value' => date('Y-m-d').' 00:00:00', 'compare' => '>=', 'type' => 'DATETIME'
Let me know if either of those approaches helps here.
Thanks!
October 21, 2016 at 1:55 pm #1180944Greg PerhamParticipantI can’t read your reply with all those spans
October 21, 2016 at 2:31 pm #1180966Greg PerhamParticipantChanging the date format does not help. I cannot use tribe_get_events. I am not marking resolved because the function should be fixed to behave as expected and as documented.
Ultimately wound up using
$events = new WP_Query( array( 'post_type' => 'tribe_events', 'tag' => 'featured', 'meta_query' => array( 'key' => '_EventEndDate', 'value' => date( 'Y-m-d 00:00:00' ), 'compare' => '>=', 'type' => 'DATETIME' ), 'posts_per_page' => 2, ) ); if( $events->have_posts() ) : etc
October 25, 2016 at 6:18 am #1182385JoshParticipantHey Greg,
I apologize for the confusion there with that previous response and the odd formatting there.
I’m glad you were able to find a solution here.
I did some further testing but I was unable to replicate the issue. If I use just:
https://gist.github.com/BeardedGinger/809353fe857ed2d50db7fde2edfe0c2a
It works and only pulls upcoming events (or in my case no events since I only tagged past events with the “featured” tag). If I remove the “eventDisplay” setting from being “list” then those past events get included.
This makes sense due to the way the filters are intended to work there. I’m curious if you maybe have some additional query alterations to possibly “suppress_filters” elsewhere on your site?
Thanks!
October 26, 2016 at 10:57 am #1183318Greg PerhamParticipantPerhaps this was fixed in the recent minor update that came out a day or two after I created this topic. It’s now working as expected. I did verify the behavior on Twentysixteen with all other plugins disabled before posting.
October 27, 2016 at 6:27 am #1183674JoshParticipantHey Greg,
Awesome! I’m glad this has been resolved.
There may have been an unrelated issue that was addressed in that that fixed this particular issue here.
I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.
Thanks!
-
AuthorPosts
- The topic ‘tribe_get_events returns posts when it should not’ is closed to new replies.