How to edit this Java Script code to hide "product recommendations" from specific pages with a tag

Hey I wanted to hid “You May Also Like” product recommendation section from few pages with a specific tag which is rjq.

I got with a developer here in shopify community and he was very kind to help me with the code which solved 50% of my problem. So now the problem is after applying the code it removed the product recommendation section from all the product pages which is not what I wanted.

I only want the section to be removed from products having rjq tags. Here is the code I used

.js-section__product-related { display: none; }

Please customize the code to only display; none to products with rjq tag

Thank you

Hey @Ali2023 !

Certainly! You can modify the code you provided to only hide the “You May Also Like” section on product pages with the “rjq” tag by adding an additional CSS selector to target the section on those specific pages.

Here’s the updated code:

{% if product.tags contains 'rjq' %}
<style>
.js-section__product-related {
display: none;
}
</style>
{% endif %}

This code first checks if the current product has the “rjq” tag, and if it does, it adds the CSS code to hide the “You May Also Like” section. If the product doesn’t have the “rjq” tag, the CSS code won’t be added, and the section will display as normal.

I hope that helps! Let me know if you have any other questions.

1 Like