Need Support Code To Link Articles Via Tag

Need Support Code To Link Articles Via Tag

NQuan088
Shopify Partner
6 0 0

Hello everyone. I have a piece of code: 

{% if article.tags.size > 0 %}

  <div class="related-posts">

    <h3>Read More:</h3>

    <ul>

      {% for tag in article.tags %}

        {% for related_post in blogs[blog.handle].articles %}

          {% if related_post.tags contains tag and related_post.handle != article.handle %}

            <li><a href="{{ related_post.url }}">{{ related_post.title }}</a></li>

          {% endif %}

        {% endfor %}

      {% endfor %}

    </ul>

  </div>

{% endif %}

This code has the effect of creating internal links between articles with the same tag as read more . I have a problem. If I put this code on the website it worked. But it only retrieves articles with the same post category. As for the articles that are not in the same category of articles, it will not be retrieved. I changed the code blogs[blog.handle].articles to blog.articles. But it still doesn't work. I use Sense 3.0.0 theme

Can someone help me with this problem.

Thank you!

 

Replies 0 (0)