Monday, August 13, 2012

How to use same Database for different wordpress installed?

Hello Everyone,
Sometimes we have some big projects in wordpress where we require clients feedback on every update, for new website which is not yet live, is fine but for live sites if changes are frequent we require some testing website to test our functionality, before making the changes in the live website.
So, I am sharing with all of how to do this.

Assuming that your website is live now for testing purpose you are building another duplicate.
Say your live url is :http://www.yourdomain.com

Step1: Create a folder in the root so that you can open it as http://www.yourdomain.com/duplicate

Step2: Copy the whole website there, even the wp-config.php should be same.

Step3: Go to wp-includes/wp-db.php go around line no. 598 (Wordpress 3.3) or I will say to find
function set_prefix there where the foreach loop ends add $this->options = 'wpdup_options'; where "wpdup" is the new prefix which we set for the new installation.

Step4: Go to your phpmyadmin, duplicate the wp_options table and edit it with table name as wpdup_options and there change the options as required, say in option_name where there is "siteurl" put the option_value as "http://www.yourdomain.com/duplicate".

Step5: Check that all the links are directed to the new link, and you are done.

Hope it will help you!!!