# Show post numbers

**URL:** https://meta.discourse.org/t/show-post-numbers/66097
**Category:** Feature
**Created:** [July 13, 2017, 2:07am UTC](https://meta.discourse.org/t/show-post-numbers/66097 "2017-07-13T02:07:11Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![ccatlett2000](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ccatlett2000/32/75202_2.png) [@ccatlett2000](https://meta.discourse.org/u/ccatlett2000)
#### Post date: [July 13, 2017, 2:07am UTC](https://meta.discourse.org/t/show-post-numbers/66097/1 "2017-07-13T02:07:11Z")

</div>

Is it possible to show post numbers for each post (Or easy to do via CSS or similar). My use case is running forum mafia, where allowing users to easily refer to a post without the bulk of quoting it would be amazing.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 13, 2017, 2:09am UTC](https://meta.discourse.org/t/show-post-numbers/66097/2 "2017-07-13T02:09:22Z")

</div>

Just press the link button under each post, and the post number is visible there.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [July 13, 2017, 10:25am UTC](https://meta.discourse.org/t/show-post-numbers/66097/3 "2017-07-13T10:25:41Z")

</div>

It is hard to say if this is what you are looking for, but it should get you close.

> <https://github.com/sitepoint/discourse-theme/blob/b4b4a7218ffbbfd4ee3cf8aa7421d29c96fdc4ed/assets/stylesheets/desktop/topic-post.scss#L45-L51>

We use that CSS to put #1, #2, et al on a topic after the date/timestamp.

---

<div class="post-metadata">

### Author: ![ccatlett2000](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ccatlett2000/32/75202_2.png) [@ccatlett2000](https://meta.discourse.org/u/ccatlett2000)
#### Post date: [July 13, 2017, 12:37pm UTC](https://meta.discourse.org/t/show-post-numbers/66097/4 "2017-07-13T12:37:50Z")

</div>

Yes, it is, this is amazing 🙂

Thanks so much!

---

<div class="post-metadata">

### Author: ![rahim123](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@rahim123](https://meta.discourse.org/u/rahim123)
#### Post date: [February 3, 2023, 4:27am UTC](https://meta.discourse.org/t/show-post-numbers/66097/5 "2023-02-03T04:27:52Z")

</div>

```plaintext
a.post-date span {
  margin-right: 1em;
}

a.post-date:after {
  content: "#"attr(data-post-number);
}

```

This doesn’t seem to work anymore. Is there a current way to show post numbers?

---

<div class="post-metadata">

### Author: ![DummyCode](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dummycode/32/460183_2.png) [@DummyCode](https://meta.discourse.org/u/DummyCode)
#### Post date: [January 22, 2025, 3:00am UTC](https://meta.discourse.org/t/show-post-numbers/66097/6 "2025-01-22T03:00:38Z")

</div>

Now post a tag does not have a data-post-number identifier, this css style does not work, I do not know there is another way to solve?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [January 22, 2025, 1:04pm UTC](https://meta.discourse.org/t/show-post-numbers/66097/7 "2025-01-22T13:04:01Z")

</div>

> [@DummyCode](#):
>
> I do not know there is another way to solve?

Not without javascript.

---

<div class="post-metadata">

### Author: ![DummyCode](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dummycode/32/460183_2.png) [@DummyCode](https://meta.discourse.org/u/DummyCode)
#### Post date: [January 23, 2025, 1:34am UTC](https://meta.discourse.org/t/show-post-numbers/66097/8 "2025-01-23T01:34:21Z")

</div>

Thanks for the reply, is this a plugin that needs to be written to call the api? Or is it simply written in the theme component?

---

<div class="post-metadata">

### Author: ![DummyCode](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dummycode/32/460183_2.png) [@DummyCode](https://meta.discourse.org/u/DummyCode)
#### Post date: [January 23, 2025, 1:53am UTC](https://meta.discourse.org/t/show-post-numbers/66097/9 "2025-01-23T01:53:57Z")

</div>

Thank you very much. I have solved the problem now！

```plaintext
api.decorateCooked(() => {
          var add_post_number_timer = setTimeout(() => {
            var articles = document.getElementsByTagName("article");
            for (var i = 0; i < articles.length; i++) {
              var post_date = articles[i].getElementsByClassName("post-date");
              if (post_date.length != 0) {
                var post_number = articles[i].getAttribute("id").replace("post_", "");
                post_date[1].setAttribute("data-post-number", post_number);
              }
            }
            clearTimeout(add_post_number_timer);
          }, 500);
        }, {
        id: 'add_post_number'
    });

```

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [January 23, 2025, 3:14am UTC](https://meta.discourse.org/t/show-post-numbers/66097/10 "2025-01-23T03:14:27Z")

</div>

Awesome! You figured out how to do it. 👍

Here are a few improvements you can do:

- `api.decoratedCooked` will be deprecated and is called on every post.  
You can use `decorateCookedElement` instead, which works without jQuery.

- An `element` representing the current post is passed to the API; you can use it as your post context.

- You can work with the `schedule` function from ember to wait for the element to be rendered.

```js
import { schedule } from "@ember/runloop";
// const { schedule } = require("@ember/runloop"); // use this if running in Admin UI

api.decorateCookedElement((element, /* helper */) => {
  schedule("afterRender", () => {
    const article = element.closest("article");
    if (article) {
      article.dataset.postNumber = article.id.replace("post_", "");
    }
  });
});

```

![image](https://global.discourse-cdn.com/meta/original/4X/6/9/5/69508a767d546ef6e8427c9f55408d78276452e1.png)

---

<div class="post-metadata">

### Author: ![DummyCode](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dummycode/32/460183_2.png) [@DummyCode](https://meta.discourse.org/u/DummyCode)
#### Post date: [January 23, 2025, 4:52am UTC](https://meta.discourse.org/t/show-post-numbers/66097/11 "2025-01-23T04:52:02Z")

</div>

👍Thank you very much for the correction.
