Restricting Related Products to Tags Only

This topic has 6 replies, 3 voices, and was last updated 6 years, 1 months ago ago by Rose Tyler

  • Avatar: bart
    bart
    Participant
    February 21, 2018 at 09:04

    Good day,

    I need to restrict related products to tags only and hide related by category products. As far as I understood this is possible, however, I can’t find any recommendation on your forum. Would you mind to share some guidelines or instructions how to do that?

    Thank you in advance.

    5 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    February 21, 2018 at 11:35

    Hello,

    There is no option to choose related products query type by default but you can try to implement it by additional customization.

    Read this post https://nerdymind.com/our-blog/woocommerce-restricting-related-products-to-tags-only
    Do all the changes in the child theme.

    Regards

    Avatar: bart
    bart
    Participant
    February 28, 2018 at 16:39

    Thank you Olga, I will give it a try and will share the result.

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    February 28, 2018 at 19:44

    You are welcome!

    Regards

    Avatar: bart
    bart
    Participant
    March 11, 2018 at 11:45

    Surprisingly I have found a simple solution by editing Theme Functions for child theme (Appearance>Editor).

    In case someone will need it, simply add this code:

    add_filter( ‘woocommerce_get_related_product_cat_terms’, function( $term_ids, $product_id ){
    return array();
    }, 10, 2 );

    Thanks for the support once again.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 12, 2018 at 09:08

    Hello,

    We are glad that you sorted out.
    Feel free to ask if you have any other questions.

    Regards

  • Viewing 6 results - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.