You can access your site’s entries from your templates via craft.entries
.
{% for entry in craft.entries.section('news').limit(10).all() %}
<article>
<h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1>
{{ entry.summary }}
<a href="{{ entry.url }}">Continue reading</a>
</article>
{% endfor %}
craft.entries
supports the following parameters:
Only fetch entries with a Post Date that is on or after the given date.
{entry:snippets/date-param-values:body}
Only fetch entries that are an ancestor of a given entry within a Structure section. Accepts an EntryModel object.
Only fetch entries that are a given number of levels above the entry specified by the ancestorOf
param.
Only fetch entries that have been archived by setting this to true
.
Only fetch entries that were authored by users who belong to the group with the given handle.
Only fetch entries that were authored by users who belong to the group with the given ID.
Only fetch entries that were authored by the user with the given ID.
Only fetch entries with a Post Date that is before the given date.
{entry:snippets/date-param-values:body}
Only fetch entries at a certain level within a Structure section.
Set to false
to fetch entries which aren’t actually enabled for the current site. (By default they won’t show up.)
Only fetch entries that are a descendant of a given entry within a Structure section. Accepts an EntryModel object.
Only fetch entries that are a given number of levels below the entry specified by the descendantOf
param.
If set to true
, entries will be returned in the same order as the IDs entered in the id
param.
Only fetch the entry with the given ID.
Indexes the results by a given property. Possible values include 'id'
and 'title'
.
Limits the results to X entries. Defaults to null
(no limit).
The site the entries should be returned in. (Defaults to the current site.)
Can also use siteId
.
Only fetch the entry which is the next sibling of the given entry within a Structure section. Accepts either an EntryModel object or an entry’s ID.
Skips the first X entries.
For example, if you set offset(1)
, the would-be second entry returned becomes the first.
The order the entries should be returned in. Possible values include 'title'
, 'id'
, 'authorId'
, 'sectionId'
, 'slug'
, 'uri'
, 'postDate'
, 'expiryDate'
, 'dateCreated'
, and 'dateUpdated'
, as well as any textual custom field handles. If you want the entries to be sorted in descending order, add “desc
” after the property name (ex: 'postDate desc'
). The default value is 'postDate desc'
.
Only fetch entries which are positioned after the given entry within a Structure section. Accepts either an EntryModel object or an entry’s ID.
Only fetch entries which are positioned before the given entry within a Structure section. Accepts either an EntryModel object or an entry’s ID.
Fetch entries based on their Post Date.
Only fetch the entry which is the previous sibling of the given entry within a Structure section. Accepts either an EntryModel object or an entry’s ID.
Only fetch entries that are related to certain other elements. (See Relations for the syntax options.)
Only fetch entries that match a given search query. (See Searching for the syntax and available search attributes.)
Only fetch entries that belong to a given section(s). Accepted values include a section handle, an array of section handles, or a SectionModel object.
Only fetch entries that belong to a given section(s), referenced by its ID.
Only fetch entries which are siblings of the given entry within a Structure section. Accepts either an EntryModel object or an entry’s ID.
Only fetch the entry with the given slug.
Only fetch entries with the given status. Possible values are 'live'
, 'pending'
, 'expired'
, 'disabled'
, and null
. The default value is 'live'
. null
will return all entries regardless of status.
An entry is 'live'
if it is enabled, has a Post Date in the past and an Expiration Date in the future. An entry is 'pending'
if it is enabled and has Post and Expiration Dates in the future. An entry is 'expired'
if it is enabled and has Post and Expiration Dates in the past.
Only fetch entries with the given title.
Only fetch entries of the given entry type. This parameter accepts an entry type handle.
Only fetch the entry with the given URI.