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).

/**
 * Show total share count for included total
 *
 * @author Bill Erickson
 * @link 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 );

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk