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 Like

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 Like

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 Likes

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 Like

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 Like

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

Hi Richard,

I am using the latest version of this plugin but unfortunately, it does not work.

I have the same problem as Nick:

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:


Would you be able to assist here, please?

This is finally on the top of my list so I will be working on this plugin tomorrow, fixing some bugs and answering your questions. Sorry for the long delay.

3 Likes

Thank you, much appreciated.

Please note that my issue got fixed by flushing the object cache of my main website.

2 Likes

Did you configure the “Enable Discourse Webhook” setting?

I have thoroughly tested the plugin, fixed a few bugs, two of them having to do with failing to update the cache of the shortcode output, updated the readme and pushed a new version.

I still see one large issue where [discourse_topics] shortcodes with different categories do not work correctly. This will take quite an amount of work to fix. I will address that one first thing after my upcoming vacation.

4 Likes

I have only one shortcode in use in this instance, so I’m not sure if I should be having issues. I would like to show private topics, but only of certain categories (which are collected under a single parent category). Neither the single parent category ID (e.g. [discourse_topics category="5" ... ]) or each of the subcategory IDs (e.g. [discourse_topics category="6,7,8,9,17" ... ]) seems to limit the results to these categories (additional private topics are shown that should not be). I’m wondering if this is the currently expected behavior (that you’ll be addressing)?

Multiple category ID’s are not supported.

That is not expected behavior indeed.

A quick fix could be to disable the Display Private Topics checkmark in the settings tab. That won’t solve the issue of the wrong category(/ies) being selected but it will stop the private topics from appearing in Wordpress.

Can you please check your logs on Discourse side and search for the API call that is being made? The API call will be triggered when you edit and change the page on Wordpress side.