0.1 C
New York
Monday, February 3, 2025
Open a Free Demat Account

Facebook and G + comments lost after migration from HTTP to HTTPS

Have you migrated your WordPress site from HTTP to HTTPS and now lost all Facebook and / or Google Plus comments? Don’t worry, they can be recovered!

After I migrated this blog to HTTPS in January 2016, it bothered me to lose a lot of comments I had accumulated on posts. Ever since the possibility arose I have used Google Plus as an alternative platform to native WordPress comments. User interaction wasn’t bad, it was a shame to lose everything.

As you know it is possible to implement Facebook and Google Plus comments in WordPress pages and posts. To get comments from Facebook and Google+ about the URL we are viewing, a WordPress variable is used: the_permalink or alternatively get_permalink . To fix this I would have to change this variable for all posts prior to the migration date, i.e. request comments for URLs in HTTP up to the migration date, and after the migration date request the current URL, with HTTPS. Let’s see the details better.

To enable Facebook and Google Plus comments on a website like WordPress, you need to insert the relevant script in the template.

Enter your Facebook comments

Enter your Google Plus comments

The variable the_permalink

Have you noticed that both scripts use the same the_permalink variable to tell platforms the comment URL? The_permalink is used by WordPress to indicate the URL of the current page, we can use it to retrieve the URL of the page we want to get comments from.

Now let’s see how to change this variable based on the post date.

Migration Comments Facebook & Google Plus

The script below is done for Google Plus comments, but the concept is the same for Facebook comments too.
The lines I wrote are commented, I hope they are clearly interpreted, in case it is not, ask me 🙂 I am a trivial PHP beginner and this script is certainly not elegant for a programmer, but it does its duty and is already good: ) Of course, if you have any advice to improve it, leave a comment, it would be very valuable!

Note: I used the last script block to decide exactly when to request the new URL ( $ compare_time variable ). The last lines are used to show on the screen the sum of Google+ comments accumulated on the 2 respective versions of the URL: HTTP and HTTPS. In fact, I noticed that some 2015 posts (prior to the migration, and therefore the script would have requested with HTTP) had accumulated more comments in 2016, on the HTTPS version. So if I had used the January 1, 2016 migration date to get the script to work I would have missed a lot of comments in previous posts. Use this feature to scroll through pre-migration posts and decide if it’s worth getting the script to act before the migration date.

Once you see where the comments start growing with the new URL you will know what date to set in the script and you will be able to comment on the last block of lines.

Total viewing of comments on HTTP and HTTPS. When to activate the script?

PS: you could also make a plugin if someone helped me: D half is already done, the options page to set the migration date is missing and also the script should be migrated from echo to return, which at the moment I am not yet able to do.
Link to the repository

  • github.com
  • stackoverflow.com
  • wordpress.org/support

Uneeb Khan
Uneeb Khan
Uneeb Khan CEO at blogili.com. Have 5 years of experience in the websites field. Uneeb Khan is the premier and most trustworthy informer for technology, telecom, business, auto news, games review in World.

Related Articles

Stay Connected

0FansLike
3,912FollowersFollow
0SubscribersSubscribe

Latest Articles