Add username to twitter share

The following code snippet will add your twitter username to the end of a tweet shared from your website. Add this code to your theme’s functions.php file or a core functionality plugin.

Make sure to change “billerickson” to your twitter username.

 * Shared Counts - Add username to twitter share
 * @link
 * @author Bill Erickson
 * @param array $link
 * @return array
function be_shared_counts_twitter_username( $link ) {
	if( 'twitter' == $link['type'] ) {
		$link['link'] .= '&via=billerickson';
	return $link;
add_filter( 'shared_counts_link', 'be_shared_counts_twitter_username' );

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