# 评论计数同步

**URL:** https://meta.discourse.org/t/comment-count-sync/378786
**Category:** WordPress
**Created:** [2025年八月15日 19:03 UTC](https://meta.discourse.org/t/comment-count-sync/378786 "2025-08-15T19:03:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jtbayly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jtbayly/32/119510_2.png) [@jtbayly](https://meta.discourse.org/u/jtbayly)
#### Post date: [2025年八月15日 19:03 UTC](https://meta.discourse.org/t/comment-count-sync/378786/1 "2025-08-15T19:03:30Z")

</div>

我遇到的问题似乎与 WP-Discourse 日志中的这些错误有关：

`[2025-08-14 20:28:35] comment.ERROR: sync_comments.response_error {"message":"","discourse_topic_id":"2464","wp_post_id":20434,"http_code":""} `  
`[2025-08-14 20:36:04] comment.ERROR: sync_comments.response_error {"message":"","discourse_topic_id":"727","wp_post_id":12097,"http_code":""} `

但是日志中没有关于同步失败原因的消息，所以我不知道该如何调试。

我自己留下了一条评论，并在日志中看到了这个：

`[2025-08-15 18:44:39] comment.INFO: sync_comments.success {"post_id":22491}`

该帖子现在在页面顶部正确显示有一条评论的元数据。

 ![Screenshot 2025-08-15 at 14.58.24](https://global.discourse-cdn.com/meta/original/4X/7/6/9/769adda66d859408535eabfee3646fcf806a23fa.png)

但是，页面底部仍然显示“Start the discussion at …”而不是“Join the discussion”，尽管现在已经有一条评论了。

有人有什么建议吗？

我选择了“Only Import Moderator-Liked”（仅导入版主点赞的），但我认为这只会影响显示哪些评论，而不影响措辞或评论计数，对吗？

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年八月18日 07:39 UTC](https://meta.discourse.org/t/comment-count-sync/378786/2 "2025-08-18T07:39:43Z")

</div>

嘿 @jtbayly，感谢你的报告。我正在尝试理解你认为这里存在的问题。根据你所说的，情况似乎是这样的：

1. 从 Wordpress 发布帖子到 Discourse 工作正常。
2. 你设置了同步评论数据 Webhook（是这样吗？）。
3. 你启用了“仅导入版主点赞”。
4. 你在日志中看到了一些同步评论错误。
5. 当你在 Discourse 中回复从 Wordpress 发布的帖子时，你看到评论计数增加，但在 Wordpress 中没有看到帖子出现。

如果暂时忽略日志，你能否解释一下你期望发生什么，以及当前状态与你的期望有何不同？

---

<div class="post-metadata">

### Author: ![jtbayly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jtbayly/32/119510_2.png) [@jtbayly](https://meta.discourse.org/u/jtbayly)
#### Post date: [2025年八月18日 17:58 UTC](https://meta.discourse.org/t/comment-count-sync/378786/3 "2025-08-18T17:58:03Z")

</div>

抱歉，我可能把上次消息的细节弄得太复杂了。

通常情况下，评论计数似乎没有从 0 增加。我实际上并没有在 WP 上_显示_任何评论。

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年八月19日 07:47 UTC](https://meta.discourse.org/t/comment-count-sync/378786/4 "2025-08-19T07:47:28Z")

</div>

我明白了！您是否设置了 Sync Comment Data 钩子？

> [@Configure WP Discourse Webhooks](https://meta.discourse.org/t/configure-wp-discourse-webhooks/311552#sync-comment-data-5):
>
> You can use webhooks to sync data between Discourse and WordPress, and enrich your integration. Reply to this topic if you have questions about how to setup the webhooks, or how they work. Setup WP Discourse First setup an endpoint in WP Discourse: Navigate to WP Discourse \> Webhooks in Wordpress admin. Select the endpoint(s) you want to enable (see below). Set a “Webhook Secret Key”, if it’s not already set. Click “Save Options”. Discourse Then create a new Webhook in Discourse (Go to /admi…

---

<div class="post-metadata">

### Author: ![jtbayly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jtbayly/32/119510_2.png) [@jtbayly](https://meta.discourse.org/u/jtbayly)
#### Post date: [2025年八月19日 13:42 UTC](https://meta.discourse.org/t/comment-count-sync/378786/5 "2025-08-19T13:42:13Z")

</div>

是的，我确实遇到了这个问题。我在 WP-Discourse 中启用了“详细的网络钩子日志”。有趣的是，从那以后，我的日志中没有出现任何失败，但它仍然不起作用。这是最新的条目：

```plaintext
[2025-08-19 00:01:11] comment.INFO: sync_comments.success {"post_id":30298} 

```

但是，以该帖子为例。WP 中的帖子 30298：

1. 已通过 WP-Discourse 自动发布到 Discourse，从而为其创建了一个主题。
2. 在 Discourse 中，已在该主题下创建了一个帖子。
3. 评论数据已通过 Webhook 从 Discourse 发送到 WP，并且 WP-Discourse 已记录成功接收。
4. 无论是否登录，是否已清除缓存，WP 中的帖子 30298 仍报告零评论。

有什么想法吗？

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年八月21日 08:31 UTC](https://meta.discourse.org/t/comment-count-sync/378786/6 "2025-08-21T08:31:05Z")

</div>

您能否提供一个日志显示评论同步成功的示例帖子链接？

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年九月3日 08:49 UTC](https://meta.discourse.org/t/comment-count-sync/378786/7 "2025-09-03T08:49:16Z")

</div>

我只是想说明一下，@jtbayly 通过私信 kindly 分享了一个例子给我，我仔细查看了一下。@jtbayly 我认为你看到的是符合预期的行为。你启用了“仅导入版主喜欢的”，评论的显示，包括评论计数的显示，都由你应用于评论的过滤器设置控制。除非我弄错了，你本质上想要的是：

- 不实际导入评论。
- 仅在链接旁边显示评论计数，以对应相应的主题。

在这种情况下，我认为你想要的配置是将“启用 Discourse 评论”设置为“显示评论链接”。

---

<div class="post-metadata">

### Author: ![jtbayly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jtbayly/32/119510_2.png) [@jtbayly](https://meta.discourse.org/u/jtbayly)
#### Post date: [2025年九月3日 18:02 UTC](https://meta.discourse.org/t/comment-count-sync/378786/8 "2025-09-03T18:02:58Z")

</div>

感谢您的帮助，@angus。更改那些设置似乎解决了问题。我想我之前有些困惑。

这是我之前设想的工作方式：

1. _导入_的评论会显示在 WP 的帖子下方。
2. 评论计数将包括 Discourse 中主题的所有回复。

我之所以选择它，是因为我_最终_希望能够实际在帖子下方显示被版主点赞的评论。但我想这与显示主题的总回复数是无法同时实现的？

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年九月15日 10:55 UTC](https://meta.discourse.org/t/comment-count-sync/378786/9 "2025-09-15T10:55:38Z")

</div>

嘿 @jtbayly，为了完成这个闭环，听起来你基本上想要的是：

- 总数，例如“45 条回复”；以及
- 精选回复显示，例如 3 条管理员喜欢的回复，

同时出现。这确实是一个开箱即用的自定义设置。但我们可以让其中的一个版本生效。回顾一下：

> 总数，例如“45 条回复”

正如我们讨论过的，这可以开箱即用。

> [@jtbayly](#):
>
> 我之所以选择它，是因为_最终_我希望能够实际在帖子下方显示管理员喜欢的评论。

当您进入那个阶段时，请在 #Support > WordPress 下创建一个新主题，届时我们可以根据您的需求来解决这个问题。

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025年九月23日 13:00 UTC](https://meta.discourse.org/t/comment-count-sync/378786/10 "2025-09-23T13:00:11Z")

</div>


