The following code snippet will add your twitter username to the end of a tweet shared from your website.
Make sure to change “billerickson” to your twitter username.
This code snippet goes in a core functionality plugin or Code Snippets.
/**
* Shared Counts - Add username to twitter share
*
* @see https://sharedcountsplugin.com/2019/03/27/add-twitter-username-to-shared-tweets/
* @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' );
Code language: PHP (php)
Filters used:
shared_counts_link