Posted on — Last updated on October 11, 2019

Recently 2.1: REST API support + new filter hooks!

Recently 2.1 includes REST API support + a couple of new filter hooks to provide even more customization tools to this already highly customizable Recent Posts widget.

Ajaxified Recently widgets will load ~15% faster now that the plugin uses the REST API to fetch them. But that’s not all, we have some nice new filter hooks too!

This release borrows a couple of nice features from Recently’s “older brother”, WordPress Popular Posts, and includes a couple of minor bug fixes and improvements that you don’t want to miss.

REST API support

Recently has the ability to “ajaxify” its widgets so that they’re loaded asynchronously, preventing caching plugins -such as WP Super Cache or WP Rocket- from turning your Recent Posts list into a static posts list.

Previously, Recently relied on the older AJAX API to do that. While it did its job fantastically, this API is somewhat slow when compared to the newer REST API introduced by the WordPress team back in 2016.

According to Delicious Brains, the REST API is around 15% faster than the AJAX API. While that might not sound like much, a 15% speed improvement is nonetheless very much welcome when performance is vital for your site’s operation. Hence, Recently now uses it too to make sure it doesn’t get in the way of your site’s loading times.

If you have been using the “Ajaxify widget” feature and you also have a caching plugin installed on your site, please remember to flush its cache after upgrading to version 2.1.

This change also means that Recently now requires WordPress 4.7 or newer. If you’re for some reason running an older version of WordPress -God forbids- you really should consider upgrading first.

The recently_pre_get_posts filter hook

This release also includes the new filter hook recently_pre_get_posts, which basically allows you to customize the query args used by Recently when fetching posts from the database.

It works pretty much the same as the existing recently_query_args filter hook, except that this one allows you to customize the query args on a per widget basis. You could, for example, have a specific Recently widget list random posts instead of recent ones.

For more details and examples, check the documentation.

The recently_parse_custom_content_tags filter hook

Recently also offers the ability to customize the HTML output of the widget, and includes a set of predefined Content Tags you can use to structure your Recent Posts as you see fit.

Starting version 2.1, you can now also include your own custom Content Tags via the recently_parse_custom_content_tags filter hook.

Cloudflare’s Rocket Loader and Recently

Cloudflare, the renowed “next-gen CDN”, has a featured called Rocket Loader that:

(…) prioritises your website’s content (text, images, fonts etc) by deferring the loading of all of your JavaScript until after rendering.

That is, all of your site’s JavaScript code is downloaded and executed right after everything else has been loaded by the browser which results in faster page loading times and thus a better overall user experience for your visitors. Unfortunately, this feature when enabled broke Recently’s ability to load its widget via AJAX.

If you’re Cloudflare user and you want to use the Rocket Loader feature you can do so now without worries as Recently 2.1 can now render its ajaxified widget just fine.

Full changelog

Head over to Recently’s GitHub repo for a complete list of changes.