مكون 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
مرحباً ريتشارد،
أنا أستخدم أحدث إصدار من هذا المكون الإضافي ولكنه للأسف لا يعمل.
لدي نفس مشكلة نيك:
لا يبدو أنه “يحدّث” أحدث المشاركات من Discourse.
يجب أن أكون أفعل شيئًا خاطئًا،
[discourse_topics source=“latest”] هذا هو الرمز المختصر الذي أستخدمه.
لقد سحب ثلاثة مواضيع من Discourse ولكن منذ ذلك الحين أضفت المزيد من المواضيع لمعرفة ما إذا كانت ستظهر على موقع WordPress الخاص بي.
لم يحدث ذلك.
جربت حدث Ajax وما زال لا يبدو أنه يجلب مشاركات جديدة :sweat:

هل يمكنك المساعدة هنا، من فضلك؟

هذا أخيرًا على رأس قائمتي لذا سأعمل على هذا المكون الإضافي غدًا، وأصلح بعض الأخطاء وأجيب على أسئلتك. آسف على التأخير الطويل.

3 إعجابات

شكرا جزيلا لك.
يرجى ملاحظة أنه تم إصلاح مشكلتي عن طريق مسح ذاكرة التخزين المؤقت للكائنات لموقعي الرئيسي.

إعجابَين (2)

هل قمت بتكوين إعداد “تمكين Discourse Webhook”؟

لقد اختبرت المكون الإضافي بشكل شامل، وأصلحت بعض الأخطاء، اثنان منها يتعلقان بفشل تحديث ذاكرة التخزين المؤقت لمخرجات الشفرة المختصرة، وقمت بتحديث ملف القراءة ودفع إصدار جديد.

لا أزال أرى مشكلة كبيرة واحدة حيث لا تعمل الشفرات المختصرة [discourse_topics] بفئات مختلفة بشكل صحيح. سيستغرق هذا قدرًا كبيرًا من العمل لإصلاحه. سأعالج هذه المشكلة أولاً بعد إجازتي القادمة.

4 إعجابات

لدي اختصار واحد فقط قيد الاستخدام في هذه النسخة، لذلك لست متأكدًا مما إذا كان ينبغي أن أواجه مشاكل. أود عرض المواضيع الخاصة، ولكن فقط من فئات معينة (والتي يتم تجميعها تحت فئة رئيسية واحدة). لا معرف الفئة الرئيسية المفرد (مثل [discourse_topics category="5" ... ]) ولا معرفات الفئات الفرعية (مثل [discourse_topics category="6,7,8,9,17" ... ]) يبدو أنها تحد النتائج لهذه الفئات (يتم عرض مواضيع خاصة إضافية لا ينبغي أن تكون). أتساءل عما إذا كان هذا هو السلوك المتوقع حاليًا (الذي ستعالجه)؟

المعرفات المتعددة للفئات غير مدعومة.

هذا ليس السلوك المتوقع بالفعل.

قد يكون الحل السريع هو تعطيل علامة الاختيار عرض المواضيع الخاصة في علامة التبويب الإعدادات. هذا لن يحل مشكلة تحديد الفئة (الفئات) الخاطئة ولكنه سيمنع ظهور المواضيع الخاصة في ووردبريس.

هل يمكنك من فضلك التحقق من سجلاتك على جانب Discourse والبحث عن استدعاء API الذي يتم إجراؤه؟ سيتم تشغيل استدعاء API عند تحرير وتغيير الصفحة على جانب ووردبريس.