Shared Counts – Change label for total field

When using the “Included Total” field with the Icons style, the output looks something like this:

With the following code, you can change it to “Shares” for multiple shares, or “Share” if there’s only one share, like this:

/**
 * Shared Counts - Change "Total" to "Shares"
 * @author Bill Erickson
 * @link https://www.billerickson.net/code/shared-counts-change-label-for-total-field
 */
function ea_shared_counts_change_total_label( $link ) {
	$classes = explode( ' ', $link[ 'class' ] );
	if( 'included_total' == $link[ 'type' ] && in_array( 'style-icon', $classes ) ) {
		$link[ 'label' ] = _n( 'Share', 'Shares', $link[ 'count' ] );
	}
	return $link;
}
add_filter( 'shared_counts_link', 'ea_shared_counts_change_total_label' );

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

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

Let's Talk