Move Shared Counts to a different hook or filter

The below code changes the “Before” theme location to use my ea_post_intro hook.

You can also provide a filter, to which the buttons will be prepended (for “before” hook) or append (for “after” hook). You can also specify a different button style to use. Ex: $locations['before']['style'] = 'block';

For more information, see the source code.

/**
 * Move Shared Counts
 * @link https://www.billerickson.net/code/shared-counts-theme-location/
 *
 * @param array $locations
 * @return array
 */
function ea_shared_counts_location( $locations ) {
	$locations['before']['hook'] = 'ea_post_intro';
	return $locations;
}
add_filter( 'shared_counts_theme_locations', 'ea_shared_counts_location' );

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