Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi !
I would like to display a specific article in a specific product page. For exemple, if article contains "Travis Scott" tag and the product contains also "Travis Scott" tag so the article display in this product page.
Is it possible ?
Thank you in advance.
Yes, it is possible to display a specific article on a product page in your Shopify store if the article and product share the same tag. To do this, you will need to:
Tag the article with the same tag that is used on the product. This will allow you to identify the article and display it on the product page.
Edit the product page template in your Shopify theme to include the code for displaying the article. This will typically involve adding a snippet of code that retrieves the article based on the tag, and then displays it on the product page.
Test the product page to ensure that the article is displayed correctly. You may need to adjust the code or make other changes to the product page template to ensure that the article is displayed in the desired location and format.
I recommend consulting the Shopify documentation or consulting a Shopify expert for help with editing your theme code and implementing this feature.
I hope this helps! Let me know if you have any other questions.
Thank you for your fast awnser.
I have already set tags on my specific product and specific article. I tried few liquid code but I don't understand why it doesn't work .
Have you got an idea ?
{% for prodTag in product.tags %}
{% for art in article %}
{% if prodTag contains art.tags %}
{{ art }}
{% endif %}
{% endfor %}
{% endfor %}
The code you provided looks like it should work for displaying an article on a product page if the article and product have the same tag. However, there are a few potential issues with the code that could cause it to not work as expected.
First, in the code, article is used as the variable for the article, but it is not defined anywhere. You will need to define this variable and assign it to the article you want to display. For example:
{% assign my_article = all_articles['my-article'] %}
This will define the my_article variable and assign it to the article with the handle "my-article". You can then use this variable in the rest of the code, like this:
{% for prodTag in product.tags %}
{% if prodTag contains my_article.tags %}
{{ my_article }}
{% endif %}
{% endfor %}
Another potential issue with the code is that the 'contains' operator is used to check if the product tags contain the article tags. However, this operator only works for arrays, not strings, so it will not work as expected with tags. Instead, you can use the contains filter to check if a string contains another string, like this:
{% for prodTag in product.tags %}
{% if prodTag contains my_article.tags %}
{{ my_article }}
{% endif %}
{% endfor %}
I hope this helps! Let me know if you have any other questions.
Ok ! I think it will help me ! Thank you
But I think I don't understand for this line :
{% assign my_article = all_articles['my-article'] %}
['my-article'] this is the name of my article ?
If yes, this will be a problem because I have a lot of articles.
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025