Skip to content

Instantly share code, notes, and snippets.

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 wooexperte/b2d3e4c10d922f800b1795c4344925c2 to your computer and use it in GitHub Desktop.
Save wooexperte/b2d3e4c10d922f800b1795c4344925c2 to your computer and use it in GitHub Desktop.
Produkte einer bestimmten Kategorie von der Shop Seite entfernen
/**
* Produkte einer bestimmten Kategorie von der Shop Seite entfernen
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'Kategorie' ), // "Kategorie" gegen Kategorie im Shop austauschen.
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment