1

I see a few answers that look, hopefully, way more complicated than I'm looking for. I simply want to loop through entries with a normal for loop like:

{% for entry in craft.entries.section('News').limit(1).all() %}
loop through entries of a specific category only here
{% endfor %}

Is there no way just to throw on something like .category('BreakingNews') onto that chain?

  • @piotrpog this is grabbing a category ID. I don't see Category ID's in my Categories control panel. I just see the full name with spaces (i don't even see a shortened camelCase reference name) – Bardo_J Jul 12 at 14:21
  • You can see category ID in Sections page. Please go to Dashboard->Setting->Sections. Each category has its ID in its URL. – Kota.M Jul 12 at 14:24
  • @Kota.M perhaps i have this setup wrong. In the Sections page, I have Section Name, Section Handle, Section Type and Entry Types. If i click on the name of the Section I have Name, Handle, Section Type and Site Settings (URL/slug) – Bardo_J Jul 12 at 14:28
  • 3
0
{% for entry in craft.entries.section('News').relatedTo(57).limit(1).all() %}

does work! 57 being the Category ID in this case. Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.