I have a client site that uses seo friendly URL's (/postname/)

Up until yesterday they were using the default permalink structure of ?p=1234

They've had it set like that for years and have had their posts shared on facebook, twitter, and other networks. The problem with changing the permalinks now is that the social media sharing badges on their site have all reset their counts to 0 because the actual URL has changed. I read that Twitter would eventually begin updating itself due to it's use of checking redirected URL's but that is not the case for facebook.

I would like to edit the code for the sharing buttons to pull in the original permalink instead of the new one. Is that possible?


$plink = get_permalink($post->ID);
$eplink = urlencode($plink);

What can I use in it's place to pull in the original p=1234 instead of the seo friendly name?


1 Answer 1


Use one of the_shortlink (complete link) or wp_get_shortlink() (bare link) both introduced in WordPress 3.0.0.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.