Changing to permalinks in wordpress keeping social proof

Joao Garin

Joao Garin / August 12, 2013

2 min read––– views


One of the things to worry when chaning URL's in any website is keeping social proof in past shared links, keeping sure that these are still valid and still counted when users visit a page.

Plugins like digg digg, or sharethis help us with this but the way they worked is based on the exact URL that was shared. So for example if someone has 100 shares on facebook on a blog post for example if they change URL these buttons will be down to zero again.

The trick is to keep post the "old URL" even if the URL has changed.

I had recently this situation in wordpress and I decided to post the solution here for the plugin I was using (digg digg) as I tried to find an easy solution online but found none.

So I changed the URL's from the default wordpress URL (?p=post_id) to a very simple (/post-name). The trick was hacking the file digg-digg.php in function dd_hook_wp_content . Chaging to the following lines :

global $wp_query;
$post = $wp_query->post; //get post content
$id = $post->ID; //get post id
$postlink = get_permalink($id); //get post link
$commentcount = $post->comment_count; //get post comment count
$title = trim($post->post_title); // get post title
<strong>//HACK BY JOAO</strong>
$sharing_url = get_permalink();
<strong>//First post id after changing to permalinks</strong>
$url_change_id = "1020";
$post_id = $id;
if ($post_id &lt; $url_change_id) {
  $url_id_postfix = "/?p=" . $post_id;
  $sharing_url = "".$url_id_postfix;
$link = explode(DD_DASH,$postlink); //split the link with '#'
$url = $link[0];
$url = $sharing_url;

So this hopefully fixes it for you guys, any question feel free to ask!.

Subscribe to the newsletter

Get emails from me about web development, tech, and early access to new articles.