Discover in this tutorial how to display the number of total listens of a podcast in a project where you use Seriously Simple Podcasting plugin.
Seriously Simple Podcasting is one of the most recommended plugins to create your own podcast on a WordPress website. In fact, I use it on both Freelandev and Sustain WP.
In addition, it has several addons that extend the functionality, one of them is Seriously Simple Stats that allows you to view the listens number of the episodes from the WordPress backend. The downside is that it does not show the total number of listens (historical).
So in this tutorial we are going to see how you can get that value and display it wherever you want thanks to a shortcode.
This may interest you whether you are an Open Metrics lover and want to publicly share the figure, or if you want to get it just for yourself.
Here’s how to do it:
Instructions for creating a shortcode to display the total number of listens to a podcast
1. Create the shortcode
Add the following code at the end of functions.php or in your functionality plugin:
In this code you access the Seriously Simple Stats table
(prefix_ssp_stats) where you store the listens, save it in a transient and encapsulate it in a shortcode to display it wherever you want.
Depending on the project this request can be quite “heavy”, so inside the shortcode you create and use a transient to cache the result for a day (although you can modify it to your liking). This way you make sure that the result is displayed immediately.
2. Insert the shortcode where you want
Finally, just type
] where you want it to be displayed.
You can use the block editor to create the layout you want and enter the shortcode to display the number of total listens.
Now you know how to display the total number of listens of a podcast (created with Seriously Simple Podcasting) and make sure that this data is always updated anywhere on the web using a shortcode.
Even if you are not going to use this snippet to display the data publicly, you can use it to create a dashboard where you can add all your business relevant data.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉