Created
April 25, 2023 19:47
-
-
Save nathaningram/db1fb429ef7455e1c5d4be6a4b2d36f4 to your computer and use it in GitHub Desktop.
No Show WooCommerce Tag
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
//Hide Products with tag noshow from Shop Page | |
add_action( 'woocommerce_product_query', 'exclude_noshow_products' ); | |
function exclude_noshow_products( $query ) { | |
if ( $query->is_main_query() && is_shop() ) { | |
$tax_query = array( | |
array( | |
'taxonomy' => 'product_tag', | |
'field' => 'slug', | |
'terms' => 'noshow', | |
'operator' => 'NOT IN', | |
) | |
); | |
$query->set( 'tax_query', $tax_query ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment