I am creating an automated email for blog updates in which I want the newest blog post to stand out in the email. But to also bring under attention some other blog posts, I like to select the second and third latest blog post, and print them in the email as well, but with different styling, like this:
My idea was to make two loops: - 1 with the newest blog post: {% set posts = blog_recent_posts('default', 1) %} {% for post in posts%}
- another one with the second and third blog post: {% set posts = blog_recent_posts('default', ??????) %} {% for post in posts%}
But to be able to do this, I need to know how I can select the 2nd and 3rd post...
Hope I'm not too late in answering this, but, you may use an index while looping through each blog post. Something like this:
{% set posts = blog_recent_posts('default', 5) %}
{% for post in posts%}
{% if loop.index == 2 or loop.index == 3 %}
<!-- some HTML elements -->
{% endif %}
{% endfor %}
Hope I'm not too late in answering this, but, you may use an index while looping through each blog post. Something like this:
{% set posts = blog_recent_posts('default', 5) %}
{% for post in posts%}
{% if loop.index == 2 or loop.index == 3 %}
<!-- some HTML elements -->
{% endif %}
{% endfor %}