# 如何在用户名右侧显示“作者”

**URL:** <https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853>\
**Category:** Support\
**Created:** [2021年七月3日 12:16 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853 "2021-07-03T12:16:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neo/32/156675_2.png) [@neo](https://meta.discourse.org/u/neo)\
**Post date:** [2021年七月3日 12:16 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/1 "2021-07-03T12:16:25Z")

</div>

你好，

我希望在用户名右侧显示一个标题（属性？）为 **“author”** 的标记，以标识话题作者。

如果话题作者回复了帖子，我们就能看到右侧显示“author”字样。效果如下：

 ![Selection_813](https://global.discourse-cdn.com/meta/original/3X/2/1/2125777be1d05e71304bf0878ae014b6269757c9.jpeg)

或者

 ![Selection_814](https://global.discourse-cdn.com/meta/original/3X/a/f/af2861aa246760130e2a0d5fc91f90078d62293c.jpeg)

请问有人知道如何实现吗？  
非常感谢！❤

---

<div class="post-metadata">

**Author:** ![neo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neo/32/156675_2.png) [@neo](https://meta.discourse.org/u/neo)\
**Post date:** [2021年七月4日 09:26 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/2 "2021-07-04T09:26:05Z")

</div>

这是我的一些思考，但我不确定如何实现。

> 如果某人是话题的创建者  
> 则在用户名右侧显示“作者”  
> 否则，不显示任何内容

这是我上次用来显示帖子编号的一些代码，我觉得可以参考这个思路。

> a.post-date span {  
> margin-right: 1em;  
> }
> 
> a.post-date:after {  
> content: attr(data-post-number)“帖子”;  
> }

---

<div class="post-metadata">

**Author:** ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)\
**Post date:** [2021年七月4日 11:07 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/3 "2021-07-04T11:07:28Z")

</div>

你好 @neo，

我之前做过这种作者徽章……你可以在这里看到：↓ 希望这能帮到你 🙂

> [@Author badge on Topic Owner's posts](https://meta.discourse.org/t/author-badge-on-topic-owners-posts/171963?u=dodesz):
>
> Hello, It’s going to be really good to huge topics…where users know when the OP reply. Appear an Author badge on OP replies… I made it with CSS but I think this maybe could be a core feature or a theme component. slight_smile I target the .topic-owner class but I am sure there is a more elegant way. Like this arrow_down Thank you! slight_smile On desktop I target the .names class .topic-owner article .row .topic-body .topic-meta-data .names::after { content: "Author"; color: …

---

<div class="post-metadata">

**Author:** ![neo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neo/32/156675_2.png) [@neo](https://meta.discourse.org/u/neo)\
**Post date:** [2021年七月4日 12:54 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/4 "2021-07-04T12:54:36Z")

</div>

非常感谢！❤❤❤ 这正是我所期待的！

以下是我基于你的代码所做的自定义修改。

![Selection_813](https://global.discourse-cdn.com/meta/original/3X/0/8/08f26ed5eb03fb1d58f530edfbe55eea5d4924c5.jpeg)

另外，我注意到在桌面端，“作者”信息会在其他回复者之后被隐藏。在我的情况下，效果如下：

> // 从嵌入帖子中隐藏  
> .topic-owner article .row .embedded-posts .topic-body .topic-meta-data .names::after {  
> content: “”;  
> border: none;  
> padding: none;  
> }

但在移动端却不需要这样，这是为什么呢？🤔

---

<div class="post-metadata">

**Author:** ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)\
**Post date:** [2021年七月4日 13:19 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/5 "2021-07-04T13:19:48Z")

</div>

很高兴你喜欢 ❤🙂

如果你在 Discourse 上使用了新的过滤回复功能（Meta 也在用），则不需要使用

> // Hide from embedded posts 这一行  
> .  
> .  
> .

只需使用以下代码行 ⬇

> [@Author badge on Topic Owner's posts](https://meta.discourse.org/t/author-badge-on-topic-owners-posts/171963/6?u=dodesz):
>
> Little update! slight_smile Desktop arrow_down // Topic Owner .topic-post.topic-owner article:not(#post\_1) .row .topic-body .topic-meta-data .names::after { content: "Author"; color: var(--secondary); font-weight: bold; background: var(--secondary-medium); padding: 0px 8px; border-radius: 8px; line-height: normal; } Mobile arrow_down // Topic Owner .topic-post.topic-owner article:not(#post\_1) .row .topic-body .topic-meta-data .names .first:after { content: 'Author'; …

* * *

> [@neo](#):
>
> 但在移动设备上并不需要，这是为什么呢？🤨

因为嵌入式回复功能在移动设备上默认并未启用。🙂

---

<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:** [2021年八月3日 13:20 UTC](https://meta.discourse.org/t/how-to-display-author-on-the-right-side-of-username/195853/6 "2021-08-03T13:20:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
