Ich möchte bestimmte Produkte anhand ihres Tags aus der Suchanfrage für die Shop-Seite von woocommerce entfernen. Kann mir jemand sagen, wie das geht? Vielen Dank!
Fügen Sie dies Ihrer functions.php hinzu
function custom_pre_get_posts_query ($ q) { $ tax_query = (array) $ q-> get ('tax_query'); $ tax_query [] = array ( 'taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => array ('banana') , // Keine Produkte mit dem Tag "banana" anzeigen 'Operator' => 'NOT IN' ); $ Q-> set ('tax_query', $ tax_query); } add_action ('woocommerce_product_query', 'custom_pre_get_posts_query');