Home Blog Count Number of LinkedIn Shares With WordPress Shortcode

Count Number of LinkedIn Shares With WordPress Shortcode


There might be times when it’s necessary to count the number of times a URL has been shared to LinkedIn. Used by website owners as a type of vanity stamp, and used by marketers as a basic means of determining popularity, the shortcode below will retrieve the count, cache the result for a defined period, then return the share count to your page.

Twitter carelessly removed their own (unofficial) count API in 2015, and Google recently disabled their own +1 feature (and associated count), so it may be only a matter of time before LinkedIn follows precedent and does the same.

The Result

Given that the LinkedIn count for our BeliefMedia articles is low (the site is new), we’ll use the count for the same article on the now-retired Internoetics. The shortcode of [linkedinshares url="http://www.internoetics.com/2012/05/16/co ... gleplus/"] (snipped ). The result: 12.

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

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 to query. If left blank, the current WP page will be used.


By default we’ll return the number in a number format . Use n="0" or hardcode into the function to disable.


The result is cached for 12 hours by default.

PHP Function

Used outside of WordPress, the following function may be used. Usage of Simple Cache is required.


Title: LinkedIn Share Count With WP Shortcode or PHP
Description: Count the number of LinkedIn shares with WordPress shortcode or PHP.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | PHP Code (V0.2)

■ ■ ■

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/19oN


Please enter your comment!
Please enter your name here