# Get latest topic of a subcategory

**URL:** https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414
**Category:** Development
**Created:** [14 בנובמבר,‏ 2019,‏ 6:35pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414 "2019-11-14T18:35:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Antichrist](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/antichrist/32/159976_2.png) [@Antichrist](https://meta.discourse.org/u/Antichrist)
#### Post date: [14 בנובמבר,‏ 2019,‏ 6:35pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/1 "2019-11-14T18:35:23Z")

</div>

Is there a method to get the latest topic of a subcategory that I receive in category.subcategories? I can use category.latestTopic to get the latest topic of the main category but I can’t use it for subcategories, any smart workaround for this? I would like to show the latest topic of a subcategory when i list the subcategories.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [14 בנובמבר,‏ 2019,‏ 7:05pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/2 "2019-11-14T19:05:51Z")

</div>

I’m not 100% sure of the context (can you post your code?) but I think you should be able to treat subcategories the same as parent categories.

So `category.latestTopic` would work the same for any category/subcategory. If you loop through each of the subcategories using `category.subcategories` you should be able to use `category.latestTopic` within that loop.

---

<div class="post-metadata">

### Author: ![Antichrist](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/antichrist/32/159976_2.png) [@Antichrist](https://meta.discourse.org/u/Antichrist)
#### Post date: [14 בנובמבר,‏ 2019,‏ 7:57pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/3 "2019-11-14T19:57:04Z")

</div>

Hello, sadly it does not. behave the same way.  
Inside:

```javascript
<script type="text/x-handlebars" data-template-name="components/categories-only">
....
    {{#each categories as |c|}}
...

```

I can use `c.latestTopic`  
But inside after the above:

```javascript
...
  {{#each c.subcategories as |s|}}
...

```

I can’t use `s.latestTopic` It doesn’t return anything

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [15 בנובמבר,‏ 2019,‏ 5:00am UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/4 "2019-11-15T05:00:46Z")

</div>

Ohh I see now, thanks for the additional detail. It looks like we don’t include topics for subcategories on the category page at all, so using `latestTopic` definitely isn’t possible… I think the serializer would need to be modified in a plugin to accomplish this? (sorry, I’m not sure of the specifics for accomplishing that).

---

<div class="post-metadata">

### Author: ![Antichrist](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/antichrist/32/159976_2.png) [@Antichrist](https://meta.discourse.org/u/Antichrist)
#### Post date: [15 בנובמבר,‏ 2019,‏ 2:11pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/5 "2019-11-15T14:11:32Z")

</div>

I don’t know, sadly I’m not that experienced with Discourse or Ruby or whatever part has to be modified.  
I hope someone can come up with a solution, I’ve been trying this for days and weeks by now.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [11 באוגוסט,‏ 2023,‏ 12:49pm UTC](https://meta.discourse.org/t/get-latest-topic-of-a-subcategory/133414/8 "2023-08-11T12:49:03Z")

</div>


