Created
July 21, 2022 11:25
-
-
Save shahzaibkhan/98bdfcda94adf024fb34cd2053e4af99 to your computer and use it in GitHub Desktop.
prefix_custom_pre_get_posts_query
This file contains 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
function prefix_custom_pre_get_posts_query( $q ) { | |
if( is_shop() || is_page('awards') ) { // set conditions here | |
$tax_query = (array) $q->get( 'tax_query' ); | |
$tax_query[] = array( | |
'taxonomy' => 'product_cat', | |
'field' => 'slug', | |
'operator' => 'NOT IN' | |
); | |
$q->set( 'tax_query', $tax_query ); | |
} | |
} | |
add_action( 'woocommerce_product_query', 'prefix_custom_pre_get_posts_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment