fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Categories and Product Pages

I know you can exclude categories so the swatches do not display on the categories but I want the product to be splashed across not only the product page but several categories. That said, I do not want to see the swatches on those category pages so I exclude the categories and then I loose the swatches on the product page.

I am sure there is an easy solution to this. I can’t be the only one that needs to have the product listed on several categories. What is the trick?

Also, The swatches that show up on the categories are bigger in size then the ones on the product page. How do I change the size that appears outside of the product Pages? I could deal with the swatches on the category page if I could make them smaller or just show a list of options instead of an image.

Thank you!

Margaret Gainsley

[email protected]

Hakik Zaman

Hi Margaret,

Thanks for reaching out to us. You can try the following snippet using the Code Snippets plugin

add_filter('disable_woo_variation_swatches_archive_product', function($default, $product){
if ( is_a( $product, 'WC_Product_Variable' ) ) {
$terms_post = get_the_terms( $product->get_id() , 'product_cat' );
$target_cat_ids = [18]; //Insert the category id’s inside the target. For Example: [14,45]
if( in_array( $terms_post[0]->term_id, $target_cat_ids ) ){
return true;
}
return $default;
}
}, 10, 2);

Note: Please check the comments inside the code snippet above. Add the category id’s properly as described in the comment.

Also, The swatches that show up on the categories are bigger in size then the ones on the product page. How do I change the size that appears outside of the product Pages?

Can you please share a link from your site? It will help me to check it to understand the issue properly.

Thank You