Created
October 25, 2018 07:07
-
-
Save wooexperte/b2d3e4c10d922f800b1795c4344925c2 to your computer and use it in GitHub Desktop.
Produkte einer bestimmten Kategorie von der Shop Seite entfernen
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
/** | |
* 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