Custom wp_query with tribe_events
-
Hi,
I’ve got the following custom wp_query for the tribe_events custom post type. However, I get no results (which it should). After checking the query with the_query->request statement, I saw that the query was very strange.
This was the code which should do the trick:
<?php $args = array( 'post_type' => 'tribe_events', 'post_status' => 'publish', ); // query $the_query = new WP_Query( $args ); /* Uncomment to see the resulting SQL to debug */ // echo $the_query->request; die(); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2>Test</h2> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; ?> </ul> <?php endif; ?>
And this was the query according to the_query->request:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_tec_occurrences ON wp_posts.ID = wp_tec_occurrences.post_id WHERE 1=1 AND ( wp_tec_occurrences.post_id IS NOT NULL AND CAST(wp_tec_occurrences.end_date AS DATETIME) >= '2023-03-20 10:23:49' ) AND wp_posts.post_type = 'tribe_events' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_tec_occurrences.occurrence_id ORDER BY wp_tec_occurrences.start_date ASC, wp_posts.post_date ASC LIMIT 0, 10
If I check for the post type ‘post’ or ‘tribe_organizer’ I do get expected results. So where does this strange query statement come from?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom wp_query with tribe_events’ is closed to new replies.