Hi there
Within the UI you cannot add a query filter for something (taxonomy) and also add a custom search filter for the same thing, because the custom search filter adds a query filter for that thing where the value comes from a url parameter (that contains the filter value when the search is applied on the front end).
To achieve what you want you should remove the query filter, and set up the custom search filter as required.
That will include all 4 of your categories, including the one you do not want. Check it is working before continuing.
Now, there are two parts to the solution to this problem.
One is to make sure that no posts with the fourth category are included in the results.
You can do that by using the wpv_filter_query to modify the query arguments for the View. (See https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query)
You need to let the search filter arguments apply, but also prevent posts with the fourth category from being displayed.
Your code will need to look something like this:
add_filter( 'wpv_filter_query', 'ts_mod_tax_query', 101, 3 );
function ts_mod_tax_query( $view_args, $view_settings, $view_id ){
if ( in_array( $view_id, array( 123 ) ) ) { // Edit for View IDs
$tax_condition = array(
'taxonomy' => 'custom-cat',
'field' => 'slug',
'terms' => 'cat4',
'operator' => 'NOT IN'
);
if ( isset($view_args['tax_query']) ){
$view_args['tax_query'][] = $tax_condition;
} else {
$view_args['tax_query'] = array($tax_condition);
}
}
return $view_args;
}
(You would need to edit that for the ID of the View this should apply to, the slug of the taxonomy, the slug of the category to exclude. You can add code such as this at Toolset > Settings > Custom Code.)
That will prevent cat4 posts being shown in the results.
But there is still a problem, that cat4 will be shown in the search dropdown.
You can see an example of the kind of code you can use to prevent that here, where you can add cat4 to a blacklist: hidden link
Note, providing custom code is outside the scope of support, so if you are not comfortable adding such code to your site and modifying it to your needs you may need to recruit a developer to do that for you (see https://toolset.com/contractors/).