<pre><code>{% for entry in craft.entries.section('News').relatedTo(57).limit(1).all() %}
</code></pre>

<p>does work! 57 being the Category ID in this case. Thanks for the help.</p>

CC BY-SA 4.0
2019-07-12T16:43:38.360Z
2019-07-12T16:43:38.360Z
Bardo_J
<p>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:</p>

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

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

CC BY-SA 4.0
2019-07-12T14:10:43.830Z
https://craftcms.stackexchange.com/a/18951/9038
Piotr Pogorzelski
CC BY-SA 4.0
2019-07-12T14:21:30.057Z
@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
CC BY-SA 4.0
2019-07-12T14:24:33.583Z
You can see category ID in Sections page. Please go to Dashboard->Setting->Sections. Each category has its ID in its URL.
Kota.M
CC BY-SA 4.0
2019-07-12T14:28:45.943Z
@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
CC BY-SA 4.0
2019-07-12T14:30:36.967Z
Could you move your mouse cursor on a category's Name? I suppose a URL shows up, and it has the category's ID.
Kota.M
CC BY-SA 4.0
2019-07-12T14:37:01.230Z
@Kota.M I don't see any hover state, but if I inspect the link with dev tools, I see a data-id attribute with an integer in there. Surely that can't be the way one parses a category?
Bardo_J
CC BY-SA 4.0
2019-07-12T14:42:55.217Z
Sorry, I misunderstood. I thought it is section. But I suppose you can get a category by its handle or ID, as well as section. In Dashboard->Setting->Categories.
Kota.M
CC BY-SA 4.0
2019-07-12T14:52:45.003Z
@Kota.M I figured out where to expose those Category ID's. In the Dashboard, select Categories and under the list of the Category Groups, there's a little gear icon that lets you check a box that adds and ID column.
Bardo_J
CC BY-SA 4.0
2019-08-12T08:30:01.067Z
Possible duplicate of [Get entries which have a certain category assigned to them](https://craftcms.stackexchange.com/questions/4127/get-entries-which-have-a-certain-category-assigned-to-them)
Jamie Wade
<craft3>
in a for loop, how do i only display entries of a certain category?
# in a for loop, how do i only display entries of a certain category?

(Asked by: username_0 on 2019-07-12)

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?

**Tags:** craft3

> **Comments:**
> **username_1**: https://craftcms.stackexchange.com/a/18951/9038  
> **username_0**: @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)  
> **username_2**: You can see category ID in Sections page. Please go to Dashboard->Setting->Sections. Each category has its ID in its URL.  
> **username_0**: @username_2 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)  
> **username_2**: Could you move your mouse cursor on a category's Name? I suppose a URL shows up, and it has the category's ID.  
> **username_0**: @username_2 I don't see any hover state, but if I inspect the link with dev tools, I see a data-id attribute with an integer in there. Surely that can't be the way one parses a category?  
> **username_2**: Sorry, I misunderstood. I thought it is section. But I suppose you can get a category by its handle or ID, as well as section. In Dashboard->Setting->Categories.  
> **username_0**: @username_2 I figured out where to expose those Category ID's. In the Dashboard, select Categories and under the list of the Category Groups, there's a little gear icon that lets you check a box that adds and ID column.  
> **username_3**: Possible duplicate of [Get entries which have a certain category assigned to them](https://craftcms.stackexchange.com/questions/4127/get-entries-which-have-a-certain-category-assigned-to-them)  

---

## 1 answers

### Answer by username_0 on 2019-07-12. Score: 1

{% 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.


---

