Wp-discourse-shortcodes plugin

I’ve done some work on the discourse_latest shortcode. It’s now called discourse_topics. You can specify which topic list you want with a shortcode attribute. It currently has /latest and /top(daily|monthly|quarterly...) routes. I’ll add a categories route soon. An excerpt can be added to each topic by giving a value to the excerpt_length attribute. If you give it the value ‘full’, it will display the full posts. The data and assembled HTML is cached. You can specify the cache_duration for each shortcode. An optional webhook can be used to break the cache for the /latest route. There’s an option for updating the latest route with ajax.

The position of the category badge, avatar, username, and date can all be set with shortcode attributes. A category class is added to each list item that can be used for styling. The plugin comes with some optional styles. If they are used, adding a tile=true attribute to the shortcode gives a basic tile layout. The size and spacing of the tiles can be altered by adding some css. Overflowing text in the tiles is truncated with javascript.

I’ve also added an RSS shortcode that does basically the same thing, but displays less information. I’m not sure that it’s going to make it into the final version of the plugin.

The code is here https://github.com/scossar/wp-discourse-shortcodes. There’s a messy live demo here https://testeleven.com/. I’ll be working on it some more this week, and also writing some documentation. If anyone would like to try it out in the meantime, bug reports would be greatly appreciated.

2 Likes