how to show blog post based on tag

vandanabharti
Shopify Expert
8 0 0

<div class="blog-containers">
{%- for article in section.settings.blog1.articles -%}
<div class="blog-items `sytem{{ forloop.index }}">
<div class="design-wrap">
<div class="mobile-cato">
<div class="artical-imges">
<img src="{{ article.image | img_url: 'master' }}" alt="{{ article.title }}">
</div>
<div class="arical-title-container">
<h2 class="txxt_w1">{{ article.title }}</h2>
</div>
</div>

</div>
</div>
{%- endfor -%}
</div>-------------------i want to show blog post based on tag example tag name: "sleep" 

Reply 1 (1)

Liqiud_xPert_SJ
Shopify Partner
801 99 128

@vandanabharti 

first of all you need to list all the tags using loop.

 

{% if article.tags.size > 0 %}
    {% for tag in article.tags %}
                {% if article.tags.size > 0 %}
                    {% for tag in article.tags %}
                     <a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ tag }}</a>
                      {% break %}
                    {% endfor %}
                {% endif %}
<a href="{{ article.url }}">{{ article.title }}</a>
<a href="{{ article.url }}" title="read more">read more</a>

    {% endfor %}
    {% endif %}       

- If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response.
- Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
- Your Shopify Solution Specialist For further discussion contact: Email ID- Liqud_3xPert_SJ OR Whatsapp
- Buy a Coffee for me to get more frequently help 🙂
- Hire Me to unlock the full potential of your e-commerce store Now 🙂