CraftCMS loop through posts
{% set myEntryQuery = craft.entries()
.section('posts')
.limit(10) %}
{% set entries = myEntryQuery.all() %}
{% for entry in entries %}
{% if loop.index == 1 %}
<article class="first-post">
<h1>Featured post</h1>
{% else %}
<article>
{% endif %}
{% for asset in entry.featuredImage.all() %}
<img src="{{asset.getUrl()}}">
<img src="{{asset.getUrl('featured')}}">
<img src="{{asset.getUrl('small')}}">
{% endfor %}
<h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1>
<a href="{{ entry.url }}">Continue reading</a>
</article>
{% endfor %}
Let me know what you think on twitter @rdallaire
← Return to blog