How To Save Social Shares In WordPress When Changing Domain Names, Moving To HTTPS, or Switching Permalinks (Using Social Warfare)

Using Social Warfare to recover social shares.

It’s no secret that changing urls can be dangerous SEO-wise. In the past, I’ve written heavily about the dangers of website redesigns, migrating to a new CMS, and changing domain names. Basically, whenever you mass change urls on your site, you can run into serious SEO problems. And that includes migrating to https (which many sites are doing now).

For example, there are a number of things you need to do in order to maintain search equity during the change. That includes nailing the redirection plan, properly changing canonicals, handling the site move correctly in GSC, updating your CMS settings, and more. And the redirection plan is a critically important step that enables you to pass all signals from the old urls to the new ones (on a one-to-one basis). If you don’t, you can pay dearly.

But while many people focus on the SEO aspects of changing urls (for good reason), there’s another issue that often gets overlooked. And it can also have a big impact on your business. It’s the dreaded loss of social shares.

Losing social shares can feel like this.

URL Changes Are Inevitable
Every website needs to be redesigned at some point, and now many are switching to https. So, changing urls is inevitable for many business owners.

And if you have spent a lot of time publishing killer content that has built many social shares across posts, then the last thing you want to see is a major loss of shares. Social proof can be powerful, and watching a post go from 1,546 shares to 0 is enough to make even the toughest digital marketer cringe in horror.

So, we’ve got a tough situation. On the one hand, you want to improve your site, migrate to https, etc. And on the other hand, you can potentially lose all of your social shares in one fell swoop. And the social networks aren’t helping matters. Try and find solid documentation from them about retaining shares when you change urls. There’s really no strong documentation that covers the situation, which is unfortunate.

By the way, the major social networks should follow Google’s lead support-wise. Google provides an outstanding site move section in their webmaster support area. I wish Facebook, LinkedIn, and others would do the same, but that’s for another post.

Therefore, I guess we’re all in a tough situation when changing urls, right? Goodbye to those precious social shares… Woe is me…


Drop the pity routine! You don’t need to settle for disappearing social shares. You don’t need to watch social proof disappear into thin air. I found an excellent solution to the problem and I’m going to share it below (and walk you through how to use it). Enter Social Warfare, your social proof savior. I think you’ll like it. <- You see what I did there? :)

Social Warfare To The Rescue With “Share Recovery”
I started using social warfare a while ago for displaying social shares on my blog and it’s a great plugin with a boatload of functionality. But, it ends up they added even more functionality that is mind-blowing, especially for someone like myself who helps a lot of companies with website redesigns. They added “Share Recovery”.

As you can guess, the smart people at Social Warfare developed a solution based on a global need. And you might actually build a statue for them after using it (as you stare at your glorious social shares from your old urls, combined with shares from your new ones). Based on my experience, it’s been a great solution.

Once you install and set up the plugin, Social Warfare will check both the old url and the new url for shares, and then combine the results. So you will have both the old shares and new shares (including any brand new shares you build over time), all wrapped into one. Awesome, right?

Several options available in the UI, plus an important hack:
I’m sure you’re wondering which types of situations are handled by the plugin? Well, most url changes are covered by Social Warfare. For example, the plugin covers:

  • changing permalink structure
  • migrating to https from http
  • switching from non-www to www (or vice versa)
  • switching to a subdomain, and of course,
  • changing domain names overall

Here is a screenshot of the options in the UI:

Social warfare options for recovering social shares when changing urls.

The UI in WordPress handles most of what’s listed above, but switching domain names is a little trickier (yet still relatively easy to implement). You’ll need to add a small section of code to your theme’s functions.php file instead of using the UI. I’ll cover that scenario below.

How To Save Social Shares When Changing Domain Names
Below, I’ll cover step-by-step how to retain social shares when changing your domain name. Again, you can handle several url changes using Social Warfare, but I’ll focus on switching domain names for this example. I’ll use and to keep this simple. Also, you obviously need to be running WordPress so you can use the Social Warfare plugin.

1. Buy, Install and Register Social Warfare
The Social Warfare plugin is not free, but it’s extremely reasonable pricing-wise. A single site license is just $29, while a package for up to five websites is $135. Once you buy the plugin, go ahead and install Social Warfare just like any other plugin. Once it’s installed, you’ll need to register the plugin.

Register Social Warfare.

2. Activate Share Recovery
Once you customize the styles for your plugin (optional), you can head to the “Advanced” tab. Scroll down until you see “Share Recovery” with an on/off toggle for “Activate Share Recovery”. Click the button to activate share recovery (the button will toggle and turn green.)

Activate share recovery in Social Warfare.

3. Review Previous URL Options
Note, you don’t need to change anything here when just changing domain names. But it’s good to review this list in case you had permalink changes, you are migrating to https, etc. I mentioned these options earlier in the post and this is where you would select or enter the options matching your own specific url change. But again, for straight domain name changes, you don’t need to change these options. Keep them as-is. But again, you must still activate share recovery like we did in step 2 for domain name changes.

Social warfare options for recovering social shares when changing urls.

4. Copy and Refine Code For Your Theme’s functions.php File
I mentioned earlier that a straight domain name change isn’t handled via the options in the UI. Instead, you’ll need to use the code below and paste it into your theme’s functions.php file. Then you’ll need to edit two lines of the code. Note, if you don’t know where that file is located, contact your designer or developer. They can point you to the file quickly.

Also, make sure you back up your site before making any changes. You should be doing this anyway, but it’s always good to ensure you have a backup before you make any changes (even minor ones like this). And make sure you have a backup of your functions.php file so you can always re-upload that older version if needed.

Here’s the code you need to copy :

//* Custom Share Recovery for Social Warfare
function custom_recovery_filter($permalink) {
$current_domain = '';
$former_domain = '';
$permalink = str_replace($current_domain,$former_domain,$permalink);
return $permalink;

5. Edit The Code, Add Your Own Domain Names
The only two lines of code you need to edit are the current domain and former domain lines. This should match your WordPress install. The easiest way to know what to put here is to check your General WordPress settings. For example, if your install is in a directory, then that will look different than a root install.

General settings in Wordpress.

For this example, let’s say the WordPress install is in the /blog directory of your website. Then the two lines of code you enter would look like this:

$current_domain = ‘’;

$former_domain = ‘’;

Again, check your General Settings in WordPress, which will provide exactly what you should include in the code. If you don’t match that exactly, then share recovery will not work. I repeat, if this doesn’t match perfectly, your old shares will not show up.

6. Testing The Setup
Remember, “Share Recovery” must be turned on in the UI for this to work (covered earlier). So even though you are adding code to your theme’s functions.php file, you still need that option turned on in the WordPress settings for the plugin.

Next, once you upload the new functions.php file, there are querystring parameters you can add to your urls that will show the previous url at the top of the post (using the old domain name), while also rebuilding the Social Warfare cache. This will help you debug and test the setup. If you don’t clear the Social Warfare cache, then you might not see the true share count. So it may be working, but you simply won’t think it’s working. Note, the old url will only show up for you, since you are using the parameters I’ll give you in a second. Normal visitors will not see the old url.

So, add the following querystring parameters to the end of any url you want to test that has older social shares. Once you do, and refresh those urls, you should see the old url at the top of the post and then the share count should reflect shares from both the old and new urls.

Test the setup using hte following querystring parameters:

For example, if your new url was:

…then the url with the parameters would be:

And if you already have querystring parameters at the end of your urls, then you need to append these parameters. To do that, use an ampersand (&) versus the question mark (?)

For example:

7. Enjoy your updated share counts and benefit from social proof again.
If the share count changed (increased), you’re good to go. Please send chocolates, golf balls, or new darts to the address listed on my site. :) You can rest assured that your older posts will reflect shares from both the old url and new one (combining domains). That’s for most urls. More about that next.

Side Note: What’s up with Facebook?
Note, I’ve seen some very strange things with Facebook counts (and this is NOT just a Social Warfare issue). For some reason, Facebook will sometimes not show the accurate number of shares from the old url. It does work for many, but not for all. I can’t explain why that’s happening and I’m pretty sure nobody can. So, you might see some urls that regain almost all of their Facebook shares, while others don’t get all of them back.  Hey, those are the breaks. You can’t win them all.

Summary – Recover Social Proof Using Social Warfare For WordPress
Changing urls on a site can be a risky proposition. And although many people focus on the SEO impact, social can also take a hit. When changing urls, you can end up losing all social shares, which can be horrible when you’ve spent a lot of time and resources building those shares! But by using Social Warfare, you can regain those lost shares (and keep building them as time goes on).

I recommend trying Social Warfare. I think you’ll dig it. Good luck.



2 thoughts on “How To Save Social Shares In WordPress When Changing Domain Names, Moving To HTTPS, or Switching Permalinks (Using Social Warfare)”

  1. Hey Glenn! Thanks so much for sharing your experience with Social Warfare! I’ve had multiple people come to me letting me know about your review and we’re honored to have had you write this up. Cheers!

    • No, thank you Dustin! I’m so glad I found Social Warfare. Retaining social shares is a huge problem that many face as they change domain names, migrate to https, etc. The solution you have developed works so well. :)

Comments are closed.