Skip to content

Instantly share code, notes, and snippets.

@robertdevore
Last active August 6, 2020 18:55
Show Gist options
  • Save robertdevore/891114055154d5fcd4157c20a9987c9a to your computer and use it in GitHub Desktop.
Save robertdevore/891114055154d5fcd4157c20a9987c9a to your computer and use it in GitHub Desktop.
<?php
/**
* Shared Counts - Change URL
*/
function sitecare_change_share_url( $url = false ) {
// Make it protocol-agnostic, for preserving http requests
$new_url = '://www.NEWURL.com';
$url = $url ? esc_url( $url ) : home_url();
$home = str_replace( array( 'http://', 'https://' ), '://', home_url() );
$url = str_replace( $home, $new_url, $url );
return esc_url( $url );
}
/**
* Use Different URL for Share Count link
*/
function sitecare_change_url_share_count_link( $link ) {
// Update the link.
$link = sitecare_change_share_url( get_the_permalink( get_the_ID() ) );
return $link;
}
add_filter( 'shared_counts_link_url', 'sitecare_change_url_share_count_link' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment