Show total share count for “included total” field

The “Included Total” field in Shared Counts displays the sum total of counts across all the other buttons you’re displaying. It does not use the “total” value you see when editing a post. For instance, if you don’t include a Pinterest button on your site, it won’t include your Pinterest pins in the count total.

The code below changes the “Included Total” field to show the total across all services, regardless of whether you’re including a button. This is best used if you are only showing the total count ( you have “Count Total Only” checked in Settings > Shared Counts).

<?php
/**
* Show total share count for included total
*
* @author Bill Erickson
* @see https://www.billerickson.net/code/total-share-count
*
* @param array $link
* @param int $id
* @param string $style
* @return array $link
*/
function be_shared_counts_total( $link, $id, $style ) {
if( 'included_total' == $link['type'] ) {
$link['count'] = shared_counts()->core->count( $id, 'total' );
}
return $link;
}
add_filter( 'shared_counts_link', 'be_shared_counts_total', 5, 3 );
view raw functions.php hosted with ❤ by GitHub

Shared Counts