meta_query only check if both value are set
You can use isset to check if the values are set, and then pass them as arguments. Divide your query by 2 parts and use them as needed. // Check if both are set if ( isset( $max_age ) && isset( $min_age ) ) { $meta_query = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘min_age’, … Read more