Publishing WordPress from stage to production server

I would be very hesitant in having the same database for staging and live as any changes to the database would affect both sites (especially when using software like WordPress where there is configuration in the database). The only time that I would think of pointing to the live database would be if I was doing theme development and was not going to change the content in any way.

Your best bet is to set up a different site (and database) for staging and copy the database from live to it on a semi regular basis. This means you will need to update a number of URL’s in the wp_options table (specifically ‘site_url’ and ‘home’ – there may be others depending on your setup). If it is not possible to create another database (for example you or your client couldn’t afford to pay your provider for another one), you can change the $table_prefix variable in the wp-config file on staging.

When deploying to either staging or live (I assume you have a dev site set up elsewhere), take care not to overwrite wp-config.php file in the WordPress root directory as this holds all the database connection details.