• Resolved David Levine

    (@justlevine)


    Trying to get past events using WP_Query:

    php
    $query = new \WP_Query(
    	[
    		'post_type' => [ 'tribe_events' ],
    		'no_found_rows' => true,
    		'posts_per_page' => '11',
    		'meta_query' => [
    			[
    				'key' => '_EventEndDate',
    				'value' => '2020-12-02',
    				'compare' => '<',
    				'type' => 'DATE',
    			],
    		],
    	]
    );
    
    

    returns empty.

    But if I pass post_type => 'tribe_events (i.e. as a string instead of an array), it works fine.

    You can see the vardump of both functions on a temporary spinup at https://accused-jaguar.jurassic.ninja/

    • This topic was modified 3 years, 12 months ago by David Levine. Reason: typo in code

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gustavo Bordoni

    (@bordoni)

    Hi @justlevine,

    After a lot of trying and playing around with filters for the usual WP_Query our development team decided to try to create a wrapper for fetching events easier for people.

    
    $args = [
    	'ends_after'            => 'now',
    	'posts_per_page'        => 11,
    ];
    
    $orm = tribe_events()->by_args( $args );
    $events = $orm->all();
    

    Hopefully this helps you, otherwise let me know and I will gladly help further.

    Thread Starter David Levine

    (@justlevine)

    @bordoni thanks for the quick reply and the workaround.
    I actually came across this using the QL-Events extension for WPGraphQL.

    Seeing as this is seemingly a known quirk, I’ll relay that there (no idea how feasible it is to use TEC’s orm instead of wordpress’ built in queries.)

    Going to leave this ticket open for a little bit, and report back.

    Plugin Support Jaime

    (@jaimemarchwinski)

    It’s been a while since this thread has been active, so I’m going to go ahead and close it for now.

    Feel free to open up a new one if anything else comes up.

    Have a wonderful day!

    Thanks,?Jaime

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Bug] Using WP_Query to get past events doesnt work if `post_type` is an array’ is closed to new replies.