Created
July 29, 2025 10:06
-
-
Save stoffl6781/f7bc28b39b72505e2a3e4c5af930d3fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Try to change IN from a specivic Filter to NOT IN over Query_vars Bricks filter. | |
* | |
*/ | |
add_filter( 'bricks/query_filters/filter_query_vars', function( $query_vars, $filter, $query_id, $index ){ | |
$filter_id = $filter['filter_id'] ?? ''; | |
$allowed_filters = array( 'opuozx', 'nbhbmt'); //Bricks Widget Filter ID'S (Array) | |
if( !in_array( $filter_id, $allowed_filters, true ) ) { | |
return $query_vars; | |
} | |
// Add 'NOT_IN' to the tax_query | |
if ( isset( $query_vars['tax_query'] ) && is_array( $query_vars['tax_query'] ) ) { | |
$query_vars['tax_query'][0]['operator'] = 'NOT IN'; | |
$new_tax_query = $query_vars['tax_query']; | |
if ( isset( \Bricks\Query_Filters::$active_filters[ $query_id ][ $index ] ) ) { | |
\Bricks\Query_Filters::$active_filters[ $query_id ][ $index ]['query_vars'] = $new_tax_query ; | |
} | |
} | |
return $query_vars; | |
}, 50, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment