This custom upsells loop for WooCommerce enables you to exclude products by category or any other taxonomy. Assuming upsells have already been added using the Linked Products tab in Product Data, you can use the code to remove products in one or more categories by cat id or category slug.
The demo video shows 5 products added to Product Data > Linked Products > Upsells tab and only 3 displaying on the front end after the single mproduct as 2 products have been excluded as they belong to the excluded category added in the code on line 34
Install the Remove Category from Upsells zip folder as a new plugin or copy & paste the PHP code to the end of your child themes functions file or code snippets plugin.
You can then add your excluded taxonomy terms by slug on line 34 of the functions file including a comma separated array if adding more than 1 taxonomy term.
You must be logged in to post a comment.