Hi.
I'm trying to show a list of Blog Articles on each Collection page that has the same Product Tags used to poluate each Collection. For example, I have a Collection created to show Products with the Product Tag 'Apple'. I then want to show a list of all the Blog Articles on that Apple Collection page that have the Article Tag 'Apple'.
This is the code I have written. I'm trying to Capture the Product Tag and then get the code to use this Product Tag to find all the Blog Articles I have written with the same Tag.
I can get the Capture to capture the correct Product Tag {{ prod_tag }} but I cannot use the Capture in the next code I have to find the Blog Articles.
Can anyone help? I'm really stuck on this one. Thanks
This is all the code...
{% capture prod_tag %}
{% for tag in current_tags %}
{{ tag | remove: 'brands_' | replace: '-', ' ' }}
{% endfor %}
{% endcapture %}
{{ prod_tag }} <--- this is just a test for me to see that I the capture code works
{% for article in blogs.our-brands.articles %}
{% if article.tags contains '{{ prod_tag }}' %}
<a href="{{ article.url }}">{{ article.title }}</a>
{% endif %}
{% endfor %}
Hi Ricky
Thanks for your reply. I tried that just now but still not working.
Strange as the Capture code I've written does give the right results as shown in my screenshot. However, when I add the 'prod_tag' to the article code below this (green) it doesn't work at all.
Any ideas?
Nigel
In green your text says "shows correct tags"; plural. What is the output of prod_tag? If it is capturing multiple Tags then you need to capture and create an array, then step thru both arrays : a) loop thru the Article's Tags and then for each in turn, b) loop thru the captured Tags — to check for each Article Tag whether any of the capatured Tags matches.
e.g. if Article Tags contains "bananas, apples" and prod_tag contains "oranges, apples" you will need to loop so that the iterations are as follows:
Subject | Author | Latest Post |
---|---|---|
Subject | Author | Posted |
---|---|---|
18m ago | ||
an hour ago | ||
2 hours ago | ||
2 hours ago | ||
2 hours ago |
User | Count |
---|---|
88 | |
62 | |
61 | |
56 | |
38 |