Display a specific article in product page

Display a specific article in product page

TotoCla
New Member
6 0 0

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.

 

Replies 4 (4)

SocialAutoPost
Shopify Partner
434 59 105

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:

  1. 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.

  2. 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.

  3. 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.

Was the reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Auto post your Shopify products to Instagram, Facebook, Pinterest, LinkedIn and Twitter.
App: Social Schedular
TotoCla
New Member
6 0 0

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 %}

 

SocialAutoPost
Shopify Partner
434 59 105

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.

Was the reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Auto post your Shopify products to Instagram, Facebook, Pinterest, LinkedIn and Twitter.
App: Social Schedular
TotoCla
New Member
6 0 0

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.