How do I put tax_query in this WP_query?
-
So I have a WP_Query, that displays posts from a custom post type. It only displays posts that have a date in the future, not ones that have past.
I now want to include tax_query in this WP_Query. So that it only displays custom posts that belong to a specific term, in a custom taxonomy called event categories. My code doesn’t seem to work since i’ve added the tax_query part. It doesn’t display any messages in the browser at all. How can I make it work with the tax_query part added please?
<?php $args = array( 'post_type' => 'event', 'posts_per_page' => 100, 'meta_query' => array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '>=', 'type'=>'numeric' ), 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => '_start_ts', 'meta_value' => current_time('timestamp'), 'meta_value_num' => current_time('timestamp'), 'meta_compare' => '>=', 'tax_query' => array( // second array array( 'taxonomy' => 'event-categories', 'field' => 'slug', 'term' => $termst ) // end second array ), ); // The Query $query = new WP_Query( $args ); // The Loop while($query->have_posts()): $query->next_post(); $id = $query->post->ID; echo '<li>'; echo get_the_title($id); echo ' - '. get_post_meta($id, '_event_start_date', true); echo '</li>'; endwhile; // Reset Post Data wp_reset_postdata();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How do I put tax_query in this WP_query?’ is closed to new replies.