Exclude category from Related Products
-
Is it possible to exclude a category from Related Products?
In version 1.6.4 it was working with the following code
$args = apply_filters( 'woocommerce_related_products_args', array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'post__in' => $related, 'post__not_in' => array( $product->id ), //Mod Code starts 'post__not_in' => array($product->id), 'tax_query' => array(array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'exclude-category-slug' ), // Don't display products in the packs category in related products 'operator' => 'NOT IN')) //Mod Code Ends ) ); $products = new WP_Query( $args ); $woocommerce_loop['name'] = 'related'; $woocommerce_loop['columns'] = apply_filters( 'woocommerce_related_products_columns', $columns ); if ( $products->have_posts() ) : ?>
After last updates the related.php changed.
Any help?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Exclude category from Related Products’ is closed to new replies.