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 https://www.billerickson.net/code/shared-counts-twitter-username
* @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' );