Last active
December 16, 2015 12:25
-
-
Save richardsweeney/e6ac3fee556555a7dcae to your computer and use it in GitHub Desktop.
pre get posts WC category stuff
This file contains hidden or 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
| <?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