WordPress Plugin Question - Widget for Home Page?


(Bcguy) #1

Hi,
Does the current WordPress plugin offer the ability to show on the home page of my site the most recent posts in our Discourse plugin? Is there an easy way to do this - similar to how we have a Twitter widget that shows the most recent X number of posts we’ve done in Twitter?


(Sam Saffron) #2

Visual mock of what you would like?

WordPress plugin will only affect your WordPress install, it does not touch the Discourse install except for posting data to it.

It ships no special widgets for adding a panel to the WordPress site.


(Bcguy) #3

Sam,

I’d love to see something quite similar to the Twitter widget from a look and functionality perspective:

The above image is pulled from this example page:

It would be really helpful to pull people into the forums from the pages on the site, and since most of my pages on my site have a sidebar with too much white space - this would help me advertise the forums, and also convey the level of activity on the site - which otherwise is hard to convey.


(Johan Jatko) #4

It would be fairly easy to expose this as Discourse has a JSON API (which the whole forum runs on).

For example, this thread:
https://meta.discourse.org/t/wordpress-plugin-question-widget-for-home-page/14418/3.json

Want a category?
https://meta.discourse.org/category/support.json

Latest posts?
https://meta.discourse.org/latest.json

Some JavaScript code and you can have it running in like 20 mins =)


(Bcguy) #5

Sounds great - perhaps someone who is more software savvy than myself can do this and share it with the community - because its obviously something that anyone that is using Wordpress and Discourse is probably going to want to do.


(Adam Capriola) #6

I currently use Disqus JavaScript in a widget on my website to show the latest Disqus comments, which I really like. If that could be replicated to show Discourse comments instead, that would be amazing. (I’m trying to move off Disqus.)

This is what the Disqus JavaScript (call URL?) looks like:

<script type="text/javascript" src="http://disqus.com/forums/sixprizes/recent_comments_widget.js?num_items=25&hide_avatars=1&avatar_size=32&excerpt_length=100"></script>

You are able to customize how many comments to show, whether avatars should be shown, the avatar size, and excerpt length. The topic title and exact post (with a relative time) are linked in the output.


(Adam Capriola) #7

That exposes the latest topics I believe. Do you (or anyone) know if there is a URL for latest posts? Being able to filter by category would be nice too, if possible.


(Sam Saffron) #8

We don’t have a latest posts feed anywhere, we would need to add an endpoint for that.


(Bcguy) #9

Here is another example of how discussion threads could be added to wordpress web sites - this is an example from http://www.theverge.com. It would be great to have a wordpress widget that allowed us to easily add these to our wordpress pages / posts.

https://www.evernote.com/shard/s106/sh/7b5e89d5-c6b7-4ab0-94f4-665de400034b/331dbb49566a9e3cdf2d09d298ac679d/deep/0/Edward%20Snowden%20had%20a%20’crypto%20party’%20before%20he%20blew%20his%20NSA%20whistle%20|%20The%20Verge.png

This is a clip from this page:


(Jeff Atwood) #10

You should be able to do that by grabbing the RSS feed for latest using any RSS feed widget.

Here for example that feed is https://meta.discourse.org/latest.rss


(Molly) #11

I know this is an old topic but I was curious about this as well. I used the RSS feed widget with our site and got this:

It gets the job done but it’s not still not superb. I wonder if it has to do with our theme, but even with “show author if available” selected in the settings, you can’t see who wrote it. It’d be great if you could have the author and topic it was posted in. Polygon has a great example of that:

Is it hard for widgets to pull that information from Discourse, if we have the plugin where it replaces comments, it should be possible, right?


(Kane York) #12

Well, the RSS does have author fields.

<author>no-reply@example.com (@tobiaseigen Tobias Eigen)</author>

(Molly) #13

In terms of Discourse having author fields to be picked up? I realize that they have them, I just wonder if there’s a reason why RSS Widgets aren’t picking it up?

I tried another widget and enabled “show author” but no dice.


(Molly) #14

Also, I realized that when a staff member posts something into the staff section, it shows up on the RSS widget too, but not everyone is allowed to see it. And the “hide if” options don’t have any of the discourse categories.

I really do think this would be a worthwhile plugin if anyone was able to do it.


(Jeff Atwood) #15

Hmm, the staff posts should not show up in RSS.

I just made some staff posts on http://try.discourse.org and I don’t see them in the RSS either as me or incognito:

http://try.discourse.org/latest.rss


(Molly) #16

Ah ha! It was because they were posted in a sub category of Staff and those permissions were set for everyone to be able to see it. I’ve changed that but it’s still viewable on the front end RSS widget. I’m assuming that’s because it was already posted with the previous settings.


(Kane York) #17

If the cookies being sent with the request for latest.rss include authentication to read private topics, those private topics will be included. So, if you are, don’t include an api_key & api_username.


(Adam Capriola) #18

I put something together like this for my site. I’ll toss out the code if you or anyone wants to play around with it:

My code is kind of messy. I was originally trying to use AJAX but decided it wasn’t worth it.


Memory Usage and Blank Pages
(Bcguy) #19

Adam - can you give us a link to your site so we can see how it looks when its implemented?

Thanks.


(Molly) #20

I think it’s this one: http://sixprizes.com/