Wp-discourse-shortcodes 插件

I think I have it sorted – [discourse_latest] isn’t a proper shortcode itself, I thought I saw it somewhere. I switched it to [discourse_topics source=“latest”] and it worked.

Sheepish grin
Ray

PS How can I change the date formatting on the latest topics that show on shortcode, @simon? It shows as 2020-10-20 and I’d rather have it say Oct-20 or similar.

1 个赞

I’m fairly sure that the shortcodes plugin uses the datetime format that is set on the WP Discourse Commenting options tab. Click the link in that setting’s description to see the available options for formatting dates.

That did the trick, thanks!

Ray

1 个赞

Could you please add the usernames as avatars titles by default or as a shortcode option, and maybe another option to remove the username ( display_usernames = “false” ?). Meanwhile, if anyone needs this go to wp-discourse-shortcodes-master/lib/discourse-topic-formatter.php and replace

$avatar_image = '<img class="wpds-latest-avatar" src="' . esc_url_raw( $poster_avatar_url ) . '">';

with

$avatar_image = '<img class="wpds-latest-avatar" title="'. esc_html( $poster_username ) . '" src="' . esc_url_raw( $poster_avatar_url ) . '">';

Great plugin. Thanks!

Also, the link for categories ( more info here ) as an option inside your shortcode would be also useful.

is this plugin still being maintained? :smiley:

Yes, we (Communiteq) are maintaining it now.

https://github.com/communiteq/wp-discourse-shortcodes

2 个赞

Doesn’t seem to ‘refresh’ latest posts from Discourse.

Must be doing something wrong,

[discourse_topics source=“latest”] this is the shortcode I’m using.

It has pulled three topics from Discourse but since then I’ve added more topics to see if it pulls through on my WordPress site.

They havent.

Tried Ajax event and still doesnt seem to pull new posts through :sweat:

Is it possible to get the topics from a certain category or subcategory only?

Thanks for managing this plugin. I need this to show forum activity on the main site in wordpress.

I have a lot of topics on discourse instance but the [discourse_topics] shortcode returns blank as if there is no data - Screenshot - b9160f714e42b2677b01bcf00c041634 - Gyazo

and throws the following error on the front-end: Warning : Invalid argument supplied for foreach() in /home/customer/www/web.com/public_html/wp-content/plugins/wp-discourse-shortcodes-master/lib/discourse-topic-formatter.php on line 94

If it helps anyone, the RSS feed of my community works just fine and lists all the topics. What could I be missing here? Help appreciated :pray:

Edit and update: It seems like the topics variable is not getting populated in code.

Line 94: foreach ( $topics as $topic ) {
.....
}

//Topic variable definition
if ( $use_plugin_formatting ) {
			$topics            = $discourse_topics['topic_list']['topics'];
}

I figured it out. The checkbox to show private posts was not enabled. Beyond that, the error can be solved by adding a condition for null value for $topics variable. I did that is worked just fine.

1 个赞

If only PHP foreach would not complain about empty arrays my life would be so much better.
We’ll add this check for the next version.

1 个赞

which is the option to update discourse with users newest WP profile pic?

Use a webhook to sync user data with Discourse. - which i created and works between the two sites but doesnt update discourse users profile picture?

@RGJ

你好 Richard,

我正在使用此插件的最新版本,但不幸的是它不起作用。

我遇到了和 Nick 同样的问题:

似乎无法“刷新”来自 Discourse 的最新帖子。

一定是我做错了什么,

[discourse_topics source=“latest”] 我正在使用这个短代码。

它从 Discourse 拉取了三个主题,但从那以后,我添加了更多主题,想看看它们是否会显示在我的 WordPress 网站上。

它们没有显示。

尝试了 Ajax 事件,但似乎仍然无法拉取新帖子 :sweat:


您能否在此提供帮助?

这个终于排到我的列表最前面了,我明天会着手处理这个插件,修复一些bug并回答您的问题。抱歉耽搁了这么久。

3 个赞

谢谢,非常感谢。
请注意,我的问题已通过刷新主网站的对象缓存得到解决。

2 个赞

您是否配置了“启用 Discourse Webhook”设置?

我已经彻底测试了该插件,修复了几个错误,其中两个与未能更新短代码输出的缓存有关,更新了自述文件并推送了一个新版本。

我仍然看到一个主要问题,即具有不同类别的 [discourse_topics] 短代码无法正常工作。这将需要大量工作来修复。我将在休假后第一时间处理这个问题。

4 个赞

在此实例中,我只使用了一个短代码,因此我不确定是否应该遇到问题。我想显示私有主题,但仅限于某些类别(这些类别都归于一个父类别下)。无论是使用单个父类别 ID(例如 [discourse_topics category=\"5\" ... ])还是每个子类别 ID(例如 [discourse_topics category=\"6,7,8,9,17\" ... ])似乎都无法将结果限制在这些类别内(会显示额外的、不应显示的私有主题)。我想知道这是否是当前预期的行为(您是否会解决)?

不支持多个类别 ID。

这确实不是预期行为。

一个快速的解决方法是禁用设置选项卡中的“显示私有主题”复选框。这并不能解决选择了错误类别的问题,但可以阻止私有主题出现在 WordPress 中。

您能否检查一下 Discourse 方面的日志,并搜索正在进行的 API 调用?当您在 WordPress 端编辑和更改页面时,API 调用将被触发。