Skip to content

Instantly share code, notes, and snippets.

@richardsweeney
Last active December 16, 2015 12:25
Show Gist options
  • Save richardsweeney/e6ac3fee556555a7dcae to your computer and use it in GitHub Desktop.
Save richardsweeney/e6ac3fee556555a7dcae to your computer and use it in GitHub Desktop.
pre get posts WC category stuff
<?php
add_action( 'pre_get_posts', function( $query ) {
if ( ! $query->is_main_query() ) {
return;
}
// Du måste också se till att det är rätt query på något sätt,
// annars kommer alla queries påverkas av detta.
// Kanske is_tax( 'product_cat' ) ??
$query->set( 'tax_query', array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $sluglist,
'compare' => 'NOT IN',
),
) );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment