在更新时禁用将 WordPress 文章发布到 Discourse

Howdy, the plugin mostly works great, thanks. One issue is that I intentionally have WP articles that are old and never posted to Discourse. When any edit is made to those old WP articles, like fixing a typo, a new post is made to Discourse as if that WP article was brand new. That notifies our users about old content they don’t want to see.

Is there a way to disable this behaviour? Thanks.

Hey Sam,

The plugin gives you various options for deciding when content in Wordpress is posted to Discourse which also cover the publication of old posts. Firstly, check out the “Publishing” settings in WP Discourse which will set the default publication options. Then also check out the WP Discourse sidebar in the post itself when it’s being created or edited.

For more background on both, see

您好,我遇到了和 @samtuke 同样的行为,并且找不到解决办法。

如果编辑者修改了之前未在 Discourse 上发布的旧 WordPress 文章中的内容(例如拼写错误),它会自动发布为一个新主题。我希望阻止这种情况发生,只发布新撰写的帖子。

我猜我可以添加一个 hacky hook 来检查 post_ID 是否大于 $lower_treshold_of_post_ID_I_want_to_publish,但也许有更好的解决方案。

谢谢。

1 个赞

嘿@ajolo2ky,你能分享一下你当前的发布设置吗?如果可以的话,请分享日志查看器中的“meta”文件。

好的,

这是发布设置:

这是我在日志中看到的内容,在编辑纠正了 2023 年(旧的——我不想让它发布到 Discourse)帖子中的某些内容之后:

[2025-03-12 14:33:09] publish.INFO: create_post.post_success {"wp_title":"title","wp_author_id":"1","wp_post_id":7} 
[2025-03-12 14:33:09] publish.INFO: create_post.body_valid {"wp_title":"title","wp_author_id":"1","wp_post_id":7} 
[2025-03-12 14:33:09] publish.INFO: create_post.after_publish {"post_id":7,"remote_post_type":"create_post","discourse_post_id":"2","discourse_topic_id":"9","discourse_permalink":"https://discourse.mydomain.com/t/title/9"}

我无法公开分享元内容,但如果这有帮助,我很乐意私下分享。
谢谢!

感谢分享。现有文章在编辑后被发布的原因很可能是因为您启用了“自动发布”,这意味着在编辑器中“发布帖子到 Discourse”复选框将被自动选中。

您使用的是“经典”WordPress 编辑器:

还是新的(Gutenberg)编辑器?

是的,这就是原因,但我期望的行为是发布新文章,而不是已编辑的文章。我们正在使用 Gutenberg。

我知道我可以禁用默认行为,然后在 Discourse 上手动选择要发布的新帖子,但我希望有一个更好的解决方案 :slight_smile:

我只知道以下逻辑:

  • 新文章将发布到 Discourse
  • 已发布到 Discourse 的文章在编辑时应进行更新
  • 旧文章在编辑时不得发布到 Discourse

听起来有点令人困惑。

由于我对编码的理解仅限于使用 Virtual Basic 进行一个“hello world”测试,我猜想可以通过比较文章状态与 Discourse 状态来实现,但这可能会拖慢管理端的运行速度。或者这只是过去的情况 :man_shrugging:

考虑到设置,这将是一个非常令人困惑的配置。

@ajolo2ky 我明白你为什么会这样期望,事实上,这个问题困扰了我一段时间。过去它之所以没有这样工作,是因为在 Gutenberg 和 Classic 编辑器之间支持自动发布存在复杂性。许多人仍然使用 Classic 编辑器。

我今天早上研究了 Gutenberg 的一个可能的改进,并希望在下一个版本中进行更新。在此期间,如果你不希望在那种情况下发布帖子,只需取消选中“发布到 Discourse”或禁用自动发布。

如果/当包含更新行为的下一个版本发布时,我将在此处通知你。希望大约在一周内。

1 个赞

嗨,Angus,非常感谢。跟进一下,看你是否有关于此的任何更新。

谢谢!

嘿@ajolo2ky,感谢您的耐心等待。我一直在等待其他一些(无关紧要的)内容,以便发布新版本的WordPress插件。一旦插件新版本发布,我会通知您并请您测试这方面的新行为。谢谢!

1 个赞

@ajolo2ky 只是想提醒您,在插件的下一个版本 2.5.7 中,尚未发布到 Discourse 的现有 Wordpress 文章在编辑时将不会自动发布到 Discourse。此版本目前正在审查中,并将很快发布。

1 个赞

太棒了!我期待这次更新!

您好!只是想告诉您我已经升级了,插件按预期工作。非常感谢您满足此请求。

继续保持出色的工作!

1 个赞