Wp-discourse-shortcodes plugin

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
リチャード様

最新バージョンのプラグインを使用していますが、残念ながら動作しません。

ニックと同じ問題を抱えています。

Discourseから最新の投稿を「リフレッシュ」していないようです。

何か間違っているに違いありません。

[discourse_topics source=“latest”] これが使用しているショートコードです。

Discourseから3つのトピックを取得しましたが、それ以降、WordPressサイトに表示されるか確認するために、さらにトピックを追加しました。

表示されていません。

Ajaxイベントを試しましたが、それでも新しい投稿が表示されないようです :sweat:


こちらでサポートしていただけますでしょうか?

これはついに私のリストの最上位に来たので、明日このプラグインに取り組み、いくつかのバグを修正し、ご質問にお答えします。長い遅延をお詫び申し上げます。

「いいね!」 3

ありがとうございます。大変助かりました。

なお、私の問題はメインウェブサイトのオブジェクトキャッシュをフラッシュすることで解決しました。

「いいね!」 2

「Discourse Webhookを有効にする」設定を構成しましたか?

プラグインのテストを徹底的に行い、いくつかのバグを修正しました。そのうち2つは、ショートコードの出力キャッシュの更新に失敗するというものでした。READMEを更新し、新しいバージョンをプッシュしました。

[discourse_topics] ショートコードで異なるカテゴリを使用した場合に正しく機能しないという大きな問題がまだ1つ残っています。この修正にはかなりの作業が必要になります。休暇明けすぐにこの問題に取り組みます。

「いいね!」 4

このインスタンスではショートコードを 1 つしか使用していないため、問題が発生しているかどうかはわかりません。プライベートトピックを表示したいのですが、特定のカテゴリ(単一の親カテゴリの下に収集されている)のみを表示したいと考えています。単一の親カテゴリ ID(例:[discourse_topics category="5" ... ])または各サブカテゴリ ID(例:[discourse_topics category="6,7,8,9,17" ... ])のいずれも、これらのカテゴリに結果を制限していないようです(表示されるべきではない追加のプライベートトピックが表示されています)。これは現在予期される動作(対処される予定の動作)でしょうか?

複数のカテゴリIDはサポートされていません。

それは確かに予期しない動作です。

簡単な修正策として、設定タブの「プライベートトピックを表示する」のチェックを外すことが考えられます。これにより、WordPressにプライベートトピックが表示されなくなりますが、間違ったカテゴリが選択されている問題は解決しません。

Discourse側のログを確認し、行われているAPIコールを検索していただけますか?APIコールは、WordPress側でページを編集して変更したときにトリガーされます。