tribe_get_events returns posts when it should not

Home Forums Calendar Products Events Calendar PRO tribe_get_events returns posts when it should not

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1180119
    Greg Perham
    Participant

    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.

    #1180936
    Josh
    Participant

    Hey 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!

    #1180944
    Greg Perham
    Participant

    I can’t read your reply with all those spans

    #1180966
    Greg Perham
    Participant

    Changing 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
    #1182385
    Josh
    Participant

    Hey 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!

    #1183318
    Greg Perham
    Participant

    Perhaps 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.

    #1183674
    Josh
    Participant

    Hey 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!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘tribe_get_events returns posts when it should not’ is closed to new replies.