Thanks to Rahul, I successfully imported my Q&A database to AnsPress. Since I have seen this question a lot of times on AnsPress, I am posting how I did it. Hope it might help someone –
0. Backup everything you are about to change. If you are newbie like me, you never know, when and where silly mistakes are made.
1. Database structure – In my case, I converted my desired Q&A data into simple linear Q&A database, meaning single row contains Question, Answer, Category id, Tag id etc. in respective columns.
Column names are self-explanatory. (“AnsPress_Question_Id” was kept to insert anspress permanent link to the imported question. I had it for my further uses, not needed for most of the cases.)
2. Create a page in wordpress called import.
3. Create a new file called page-import.php inside active theme directory and paste the following code:
a. Update database info (hostname, database name, username, password).
b. Modify code according to your database structure.
c. Check your Category Ids, Tags Ids and User Ids from AnsPress and update the code accordingly. (e.g. while importing I had to add +3 to category id, as this was the difference between my at_qa_dump and wordpress tables)
d. Un-comment following line if you are importing from wordpress root directory (i.e. not by creating page in theme directory)-
4. Increase you PHP execution time : In my case, I changed php execution time to 50,000 (as my database was very large, 30K Q&A). PHP execution time of 5,000 imported approx 2500 Q&A in my first trial. To update it, search and edit following line your server’s php.ini file –
max_execution_time = 5000
5. Open the import page (e.g. http://localhost/your-wordpress-directory-path/import/) and let the query run. Sorry, not a programmer, so my code does not show real-time progress (slight lag is there, depending on number of your imported rows).
Known Issues –
1. In user’s profile page, answer text in answer list appears blank.
2. Importing is slow.
1. I am not at all a programmer. I just did this to make my site live again. All credits to Rahul Aryan, and thanks a lot for his continuous support and help.
2. Rahul and others feel free to make the changes in this procedure, so that it can be easier for others.