I have 2 custom post types on Wordpress website - Location and Event. Location is connected with Event as meta data (for sorting). For example: some event (Event post type) is taking place in London (Location post type).
All events having in their meta data "London" are shown on page of post type Location - London. The problem is that Event post type has several categories and the one category is named Expired. But posts of all categories are displayed including "Expired". I want to hide this category from the list of posts.
The code on Location page:
$count = 0;
$paged = 1;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
}
$args = array(
'post_type' => 'event',
'paged' => $paged,
'meta_query' => array(
array( 'key' => 'location', 'value' => get_the_ID() ),
),
);
$tmp_query;
global $wp_query;
$the_query = new WP_Query( $args );
$post_ids = array();
if ( $the_query->have_posts() ) :
if ( $template_type == 1) {
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo event();
endwhile;
}
Event category is named event_category, ID of Expired category - 2136.