Blog

WordPress

Posted on — Last updated on March 13, 2024

WordPress Popular Posts 6.4: Shortcode Enhancements, New REST API Endpoints!

6.4 introduces some quality-of-life enhancements plus some general stability fixes & improvements

Version 6.4 brings a couple of nice enhancements for the [wpp] shortcode and the [wpp_views_count] shortcode. There’s also a new /views REST API route that can be used to fetch / update the views count of your posts.

New year, new plugin release!

In 2024 we’ll say goodbye to the classic widget once WordPress Popular Posts 7.0 is out, but before that we’ll see at least a couple 6.x releases – just like this one. Here’s what’s new.

[wpp_views_count] can now render a “prettified” version of your views count

The [wpp_views_count] shortcode, introduced in version 6.3, now has the ability to display your views count in a “prettified” way.

For example, the tutorial How to create a simple image slider with vanilla JavaScript has a total of 2,525 views so far. We now have the option to display that number as 2.5k views instead by passing the word “prettify” to the number_format parameter:

[wpp_views_count number_format='prettify']

For more details have a look at [wpp_views_count] documentation.

[wpp] can now override the AJAX functionality

Before this release the Ajaxify feature (Settings > WordPress Popular Posts > Tools > Data > Load popular posts list via AJAX) was applied to all of your popular posts lists automatically.

There are some use cases though where having the ability to disable it on a per-instance basis might be handy, eg. using the [wpp] shortcode with MailPoet to send a newsletter of popular articles.

Version 6.4.0 introduces the ability to enable / disable the “Ajaxify” feature via the ajaxify parameter, where 1 is enabled and 0 is disabled:

[wpp range='all' limit=3 ajaxify=0]

To learn more about the [wpp] shortcode please head to its documentation page.

New /views REST API endpoints

WordPress Popular Posts 6.4.0 introduces two new REST API endpoints to provide developers more ways to interact with WPP’s data:

  1. GET /wp-json/wordpress-popular-posts/v2/views/{post_id}
  2. POST /wp-json/wordpress-popular-posts/v2/views/{post_id}

The first one accepts GET requests and returns the views count of a given post / page / custom post type ID. The latter takes POST requests and updates the views count for the provided post / page / CPT ID.

For brevity’s sake I won’t be listing the entire set of parameters that these endpoints can take so please head to the REST API Endpoints documentation page for more details.

Additionally, if you’re using the /wp-json/wordpress-popular-posts/v1/popular-posts/ POST endpoint in your JavaScript based application to update the views count of your posts -as I know some of you out there are- please update your code so it POSTs requests to /wp-json/wordpress-popular-posts/v2/views/{post_id} instead.

Other changes

  • Fixed a fatal issue caused by the views_count shortcode when providing an invalid time range.
  • Fixed fatal error that can happen when themes define image sizes using the array format for the crop parameter.
  • Fixed fatal error that can happen while the plugin is deleting its own transients.
  • Other minor fixes / improvements.

That’d be all for now! Enjoy!

Minor Updates & Hotfixes

6.4.2

Version 6.4.2, released on March 10 2024, patches two issues:

  • Setting up a custom default thumbnail for when there’s no post thumbnail available may result in the plugin reverting back to the stock “No thumbnail” image (forum report)
  • When using Polylang, filtering posts by category would result in the popular post list not returning any posts for secondary language(s).

Many thanks to the users who reported these (and past) issues, your contributions help make WPP better!

6.4.1

Version 6.4.1, released on Feb. 25 2024, adds support for .webp images.

WebP is an open source, modern image format developed by Google that provides better compression for your images which generally results in smaller image files while maintaining good quality. It’s been widely adopted by all major web browsers -except for Internet Explorer which is EOL now anyways- and so it’s safe to use today.

Since version 5.8 WordPress now grants the ability to upload and use .webp images on your site without requiring third party plugins.

From WordPress Popular Posts 6.4.1 and on if your posts use .webp images as Featured Images the plugin can now use said images to generate .webp thumbnails.

Note though that if your site is still using the more traditional image formats (.jpg, .jpeg, .png, etc) then WPP will only be able to generate thumbnails in those formats. If you’d like to switch to .webp you’d have to re-save your images as .webp first (see Creating WebP Images for more details), only then WPP will be able to serve .webp thumbnails for your popular posts.