A | B | C | D | E | |
---|---|---|---|---|---|
1 | Follow these steps to use this spreadsheet to export your comments from Disqus and import them into your Wordpress database | ||||
2 | |||||
3 | Step 1 | Make a copy of this Google Spreadsheet | |||
4 | Go to File -> Make a copy | ||||
5 | |||||
6 | Step 2 | Get an export of all the published posts from your blog. | |||
7 | Run this query in your Wordpress database and copy it into the 'Blog posts' tab of this spreadsheet. If you don't know how to do this, then look into PHPMyAdmin, or MySQL Workbench or your hosting CPanel - there are many ways to do this, so it's not possible to describe all the different methods here. Note: please ensure you keep the yellow column on this sheet. You may empty it, but it is used in Step 5 | ||||
8 | select ID,post_date,post_name,post_title from wp_posts where post_type='post' and post_status='publish'; | ||||
9 | |||||
10 | Step 3 | Get a list of the Disqus comments that are already imported to Wordpress | |||
11 | If your WP blog already has some Disqus comments in the database, then this step is required in order to avoid duplicate comments. Run this SQL statement in your database: | ||||
12 | select comment_agent from wp_comments where comment_agent like 'Disqus/%'; | ||||
13 | Copy the results from this query into the sheet 'Existing Disqus comments' - they will be matched when you generate the import SQL | ||||
14 | |||||
15 | Step 4 | Create a Disqus API application | |||
16 | Go to | https://disqus.com/api/applications/ | |||
17 | Login with an administrator account and then follow the prompts to create an application. This will give you API keys which you should copy into the 'Settings' tab of this spreadsheet | ||||
18 | |||||
19 | Step 5 | Finish configuration in Settings | |||
20 | Change the URL on the 'Settings' tab to point to your Wordpress website | ||||
21 | |||||
22 | Step 6 | Run the Disqus Export | |||
23 | If you have already used the sheet for a Disqus export, please start by selecting the option "Clear previous export" from the Add-ons menu under "Disqus Export". If you haven't already run any scripts in this project, you will be asked to authorise the scripts to run. In the Add-ons menu under "Disqus Export" select the option "Start/Continue Disqus Export". The script will export your comments from Disqus using the API and these will be copied to the 'Disqus Export' tab of this spreadsheet. You may have to run this script multiple times because if you have many blog posts or comments you will exceed the maximum script execution time allowed by Google. Once the script has successfully exported the comments from a blog post, the "done" column on the "Blog posts" sheet will be set to TRUE, so it will be skipped the next time. | ||||
24 | |||||
25 | Step 7 | Generate the Import SQL | |||
26 | Select the Add-ons "Disqus Export" menu option "Generate Import SQL" to generate the SQL that you can use to import the exported disqus comments into your database. This will go through each row in the tab "Disqus export" and generate an SQL insert. | ||||
27 | |||||
28 | Step 8 | Import the comments into your WP database | |||
29 | First ensure you have your Wordpress blog (especially the database) backed up. You can use the plugin UpDraft plus | ||||
30 | https://www.wordpress.org/plugins/updraftplus/ | ||||
31 | Then take a copy of the last comment ID in your database (in case of issues with the export). You can use this query: | ||||
32 | select max(comment_ID) from wp_comments; | ||||
33 | Then, copy and paste the SQL statements from the "Import SQL" tab and run them in your database. | ||||
34 | |||||
35 | Step 9 | Update blog post comment_count | |||
36 | We need to manually update the comment_count in the wp_posts table to reflect the comments we just imported. Please run this SQL in your WP database: | ||||
37 | update wp_posts set comment_count=(select count(*) from wp_comments wc where wc.comment_post_ID = ID and wc.comment_approved="1") where ID in (select published_posts.ID from (select wp.ID from wp_posts wp where wp.post_type='post' and wp.post_status='publish') as published_posts); | ||||
38 | |||||
39 | Step 10 | Test! | |||
40 | Disable the Disqus plugin - login to your Wordpress dashboard, to the Plugins, and then click "Deactivate" under the Disqus plugin. You will then be able to see your comments using the Wordpress comment system | ||||
41 | |||||
42 | Step 11 | Cancellation | |||
43 | Don't forget to cancel your Disqus subscription! | ||||
44 | https://disqus.com/admin/settings/general/ | ||||
45 | |||||
46 | Troubleshooting | ||||
47 | [1] If there are any script errors, you can inspect the logs | ||||
48 | https://script.google.com/home | ||||
49 | Go to "My Executions" in the menu on the left. You will see a list of all the scripts that have been run and clicking on any of those will allow you to inspect the logs and any errors that may have happened | ||||
50 | |||||
51 | [2] ERROR 1366 (HY000): Incorrect string value: '\xF0\x9F\x8C\xB8' for column 'comment_content' | ||||
52 | If you have problems with emoji's when you copy and paste the import SQL into the database, please take a look at this Quora article I wrote | ||||
53 | https://www.quora.com/How-do-I-insert-a-record-in-a-MySQL-database-from-a-command-line-that-has-a-utf8mb4-data-type-when-the-record-has-special-symbols-and-emoticons/answer/Dagmar-Timler | ||||
54 | |||||
55 | [3] Missing comments | ||||
56 | If there are missing comments, please take a look at the script logs to see why the comment was not added to the import SQL . See above for instructions on how to check the logs. There are 3 reasons why comments would be skipped: 1) The comment already exists in the database (see tab "Existing Disqus comments") 2) The comment was duplicated in the tab "Disqus exports", which can happen if the export times out in the middle of processing comments for a particular blog post 3) The parent comment is missing - perhaps the user deleted their comment? | ||||
57 | |||||
58 | [4] Your gravatar profile picture is missing | ||||
59 | Unfortunately disqus does not provide email addresses for the comment authors, so profile pictures will not show up unless you update the comment author email address in the database. This is example SQL updating the email address for a single user: | ||||
60 | update wp_comments set comment_author_email='youremail@gmail.com' where comment_author='Name of the author'; | ||||
61 | |||||
62 | |||||
63 | Important to note | ||||
64 | Do not change any of the names of the sheets otherwise the scripts will break | ||||
65 | |||||
66 | |||||
67 | |||||
68 | |||||
69 | |||||
70 | |||||
71 | |||||
72 | |||||
73 | |||||
74 | |||||
75 | |||||
76 | |||||
77 | |||||
78 | |||||
79 | |||||
80 | |||||
81 | |||||
82 | |||||
83 | |||||
84 | |||||
85 | |||||
86 | |||||
87 | |||||
88 | |||||
89 | |||||
90 | |||||
91 | |||||
92 | |||||
93 | |||||
94 | |||||
95 | |||||
96 | |||||
97 | |||||
98 | |||||
99 | |||||
100 |