CraftCMS loop through posts

{# Create an entry query with the 'section' and 'limit' parameters #}
{% set myEntryQuery = craft.entries()
.section('posts')
.limit(10) %}


{# Fetch the entries #}
{% set entries = myEntryQuery.all() %}

{# Display the entries #}
{% 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>
{# {{ entry.blogBody }} #}
<a href="{{ entry.url }}">Continue reading</a>
</article>

{% endfor %}

Let me know what you think on twitter @rdallaire

← Return to blog