Hide low share counts

If you’re using the “Included Total” option to display your total share count, the code below will let you hide the count if it is below a certain threshold.

In the code below, we are only showing the total if it is greater than 100.

This code snippet goes in a core functionality plugin or Code Snippets.

/**
 * Dont display low share counts
 *
 * @author Bill Erickson
 * @see https://sharedcountsplugin.com/2019/03/27/hide-low-share-counts/
 *
 * @param array $link
 * @param int $id
 * @param string $style
 * @return array $link
 */
function be_shared_counts_remove_low( $link, $id, $style ) {
	if( 'included_total' !== $link['type'] )
		return $link;
	$minimum_share_count = 100;
	$count = shared_counts()->core->count( $id, 'included_total', $echo = false, $round = false );
	if( $count < $minimum_share_count )
		$link['count'] = 0;
	return $link;
}
add_filter( 'shared_counts_link', 'be_shared_counts_remove_low', 10, 3 );

Filters used:

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor 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.