I'm confused about the new .one()
argument in craft 3
If I want to grab all entries I write:
{% for entry in craft.entries.section('thing').all() %}
{{ entry.title }}
{% endfor %}
Alls is nice and well. 20 something entries are returned.
But I want to fetch only the latest entry so instead of .all()
I use .one()
(which was formerly .first()
)
But when I write:
{% for entry in craft.entries.section('thing').one() %}
{{ entry.title }}
{% endfor %}
It returns the error:
Impossible to access an attribute ("title") on a string variable ("3").
When I write:
{% for entry in craft.entries.section('portfolioEntry').limit(1).all() %}
{{ entry.title }}
{% endfor %}
Then it works. But that's not the right way, is it?