# Topic ID as a variable?

**URL:** https://meta.discourse.org/t/topic-id-as-a-variable/374168
**Category:** Development
**Created:** [July 14, 2025, 6:48pm UTC](https://meta.discourse.org/t/topic-id-as-a-variable/374168 "2025-07-14T18:48:32Z")
**Posts on this page:** 1
**Showing post:** 14

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [September 25, 2025, 3:52pm UTC](https://meta.discourse.org/t/topic-id-as-a-variable/374168/14 "2025-09-25T15:52:20Z")

</div>

What I ended up with is a more discreet showing of the topic ID. It’s still not searchable, but I’ll live with it until what I really need becomes a reality.

```plaintext
<script type="text/discourse-plugin" version="0.5">
api.decorateWidget('post-meta-data:after', dec => {
  if (dec.attrs.post_number === 1) {
    const topic = dec.getModel().get('topic');
    return dec.rawHtml(`<div class="post-info topic-id"><b>&nbsp#${topic.get('id')}</b></div>`);
  }
});
</script>

```

Problem is that this code is now outdated and I don’t know how to fix it.  
What should it be updated to in order to be compliant?

---

_[View the full topic](https://meta.discourse.org/t/topic-id-as-a-variable/374168)._
