Home Blog Insert Live SoundCloud Play Counts, Download Counts, Comment Counts, and Like Counts...

Insert Live SoundCloud Play Counts, Download Counts, Comment Counts, and Like Counts in WordPress with Shortcode (without the API)


On Monday we provided the first of a few variants of shortcode that would render a SoundCloud audio player in your WordPress website. This article will provide code that’ll periodically mine SoundCloud for a play count, download count, comment count, or like count. Because we’re scraping the freely provided meta data, use of the API isn’t required.

The Result

To demonstrate the code we’ll mine the details of a cheesy Australian Bachelorette podcast from The Daily Telegraph (Australia). By default we’ll render the play count, so [soundclouds url="https://soundcloud.com/daily-telegraph/the-bachelorette-model-david-bites-the-dust-in-show-two"] will return the value of 0 (bolding is mine). To return the number of downloads, we’ll add the type attribute as follows: [soundclouds url="https://soundcloud.com/daily-telegraph/the-bachelorette-model-david-bites-the-dust-in-show-two" type="downloads"], and the shortcode will return the value of 0.

At the time of writing there aren’t any comments or likes (I wonder why?)… but if they were to be returned you should use the type attribute as follows: type="likes", or type="comments".

The Shortcode Function

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

Use of the code requires Simple Cache and BeliefMedia Meta Tags. Both are available as WP plugins. If you’re a client, both features are available by default from within the BeliefMedia plugin.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes


The url is the destination page for a single SoundCloud audio player.


The type determines what data is returned; count, downloads, comments, or likes. If nothing is specified it defaults to count.


By default the value returned will be in a number format with grouped thousands. To turn this feature off, use n="0" in your shortcode or hardcode it into the shortcode function.


The cache is the amount of time the data is stored locally. By default we cache data for 8 hours.

PHP Function

Used outside of PHP, the following function may be used. Not unlike the WordPress version, usage requires the Simple Cache and Meta Tags functions.


  • While we mine the destination page for data, results are stored locally in your own WordPress installation using the transient API. We cache the results for 8 hours by default but, if you’re comfortable doing so, you can query the SoundCloud URL more often.
  • As we’ve done in the past for Facebook, Twitter, and other counts, you might consider altering the code to return an image rather than text. For example, using the same URL as above, we can render the play count as follows:

  • Since our method of obtaining data is achieved by scraping META data, it will cease to work if SoundCloud stop providing that information.


Title: Insert SoundCloud Data with WP Shortcode or PHP
Description: Insert Live SoundCloud Play Counts, Download Counts, Comment Counts, and Like Counts in WordPress with Shortcode (without the API).
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

■ ■ ■

Interested in WordPress and Web Design? Subscribe to our list and we'll send you subscriber-only tools and plugins

Short URL for this post: http://shor.tt/19oO


Please enter your comment!
Please enter your name here