I am going to change wordpress permalinks and will do 301 redirect from old to new URL’s. But the problem is how can i keep my social sharing counts (like facebook,twitter, google +1) after the URL’s are changed.
Thanks
Leave a Reply
You must be logged in to post a comment.
Basically I am serving the old permalink for the old posts and the current permalink for the new posts.
Here is my code if it might help.
Create a function in your functions.php that will serve the right url for the social button :
Once you have this function edit your social like codes on your single.php file, in order to call the social_url() function for data-url or data-href of the social buttons
Twitter
Google +
Facebook
As a warning, Facebook seems to be less reliable than twitter or google + with this solution at least. Sometimes it works like a charm sometimes the likes drop 0 when a new click is made on the button, or stay at 0 from the beginning.