Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created April 25, 2023 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathaningram/db1fb429ef7455e1c5d4be6a4b2d36f4 to your computer and use it in GitHub Desktop.
Save nathaningram/db1fb429ef7455e1c5d4be6a4b2d36f4 to your computer and use it in GitHub Desktop.
No Show WooCommerce Tag
//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