Hello,
I am trying to show the latest 4 blog posts from 5 different blogs with the specific tag of ‘mustread’.
I can get it to show all the blog posts with that tag, but I want to limit the number shown to 4 and for it to show the most recent posts.
Here is my code:
{% assign blog_handles = "lives-igtv,actie-van-de-maand,nieuwe-producten,events,tips,videos" | split: "," %}
{% for handle in blog_handles %}
{% for article in blogs[handle].articles %}
{% if article.tags contains 'mustread' %}
{{ article.image.src | img_url: 'medium' | img_tag: article.title }}
{{ article.title }}
{% endif %}
{% endfor %}
I tried this from another answer on the community:
{% assign blog_handles = "lives-igtv,actie-van-de-maand,nieuwe-producten,events,tips,videos" | split: "," %}
{% for handle in blog_handles %}
{% assign check = 1 %}
{% for article in blogs[handle].articles %}
{% if article.tags contains 'mustread' and check < 4 %}
{% assign check = check | plus: 1 %}
{{ article.image.src | img_url: 'medium' | img_tag: article.title }}
{{ article.title }}
{% endif %}
{% endfor %}
{% endfor %}
But it shows again all the blog posts tagged with ‘mustread’ and not just 4.
Can someone help me with this?