Use the pre_get_posts
action to alter the main query with meta_query
arguments to only select posts with active
current_status
.
This example would work for your main posts page. See Conditional Tags for how to determine when other types of queries are run.
function wpa_current_status( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$meta_query = array(
array(
'key' => 'current_status',
'value' => 'active',
'compare' => '='
)
);
$query->set( 'meta_query', $meta_query );
}
}
add_action( 'pre_get_posts', 'wpa_current_status' );
EDIT- or within a custom query, set meta_query
arguments directly:
$args = array(
'post_type' => 'property',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'current_status',
'value' => 'active',
'compare' => '='
)
)
);
$properties = new WP_Query( $args );