Blog

WordPress

Posted on — Last updated on February 25, 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,375 views so far. We now have the option to display that number as 2.4k 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.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.

The WordPress team introduced the ability to use .webp images on your site in version 5.8, and now WordPress Popular Posts can leverage that to serve .webp images as your post thumbnails.

Note though that this doesn’t mean that WordPress Popular Posts is going to automatically convert your existing .jpg / .jpeg / .png images into .webp. The plugin will only use preexisting .webp images to generate your .webp post thumbnails.

If you’re currently using the more traditional formats (.jpg, .jpeg, .png, etc.) and 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.