WordPress.org

Ready to get started?Download WordPress

Forums

Develop New Theme for New Site, Use Same Database? (1 post)

  1. kailasa
    Member
    Posted 1 year ago #

    We are renovating our website. it is a complete over haul of the UI, wrapper, theme etc. we are doing this in a different domain-dev.url and /home/devmhydomain/ folder on the linux server. So, it's on the same box and can access the same MYSQL.

    I am trying to work out a strategy that will allow us to proceed with the WP development on the new site, but continue to use the same database, so that the blog archives will be up-to-date when we go live on the new site. I am pasting below a final "solution" posted on a six-year old thread:

    "Two Sites, Two Themes, One Database"

    it seems a bit dicey... but it could work.

    My developer says another option would be to install the new WP site on our dev.mydomain.com site where we are doing all the development, give the new WP have it's own new database and then export, migrate and import the old database into the new database. The problem is: any posts in the interim between then and when we actually go live, will not have been migrated (could be a month or more of posts)

    Another strategy could be to develop the new theme on the old site. then when we go live I just copy the blog folder over. The top level domain URL will not change, so it should work..

    My problem is that I have a different structure for the paths to CSS and JS files... I'm not sure that's a big issue because on the old site I could set up a /assets/css /assets/js to match the new site and then the new theme would point to those instead of the current top level /css and /js folders... This seems safest... I think you can develop new themes in WP with private url's right?

    OR: i could try this thing below where they suggest duplicating the wp_options table and give it a new prefix and the new site/dev domain, which will be up and running with the same archives.. then if someone posts on the old site, it automatically beings appearing on the new site.

    my developer is worried and cautions: "We have to be careful. I don't know what will happen if you install a new version of Word Press on the dev site and point to the database, if it updates the database in some way that will break the old Word press installation, then the blog will die on the old site."

    That's his worry and it's probably a good one.

    I would appreciate any advice on "best strategy" here. I really would like to use the same dBase if at all possible. As all the migration, export, import and missing interim posts looks like pain.

    Old thread which was closed six years ago:

    TWO SITES, TWO THEMES, ONE DATABASE:

    I've done this before, having 6 websites shoot out content from the same database.

    It's easy enough to do. Upload WP into both directories. Make sure they have the identical wp-config.php file.

    In the second sites directory do the following:
    In the wp-settings.php file change the options database value to something like this:

    // Table names
    $wpdb->posts = $table_prefix . 'posts';
    $wpdb->users = $table_prefix . 'users';
    $wpdb->categories = $table_prefix . 'categories';
    $wpdb->post2cat = $table_prefix . 'post2cat';
    $wpdb->comments = $table_prefix . 'comments';
    $wpdb->links = $table_prefix . 'links';
    $wpdb->linkcategories = $table_prefix . 'linkcategories';
    $wpdb->options = 'YOURNEWPREFIX_options';
    $wpdb->postmeta = $table_prefix . 'postmeta';
    $wpdb->usermeta = $table_prefix . 'usermeta';

    $wpdb->prefix = $table_prefix;

    See how I've removed $table_prefix . in the options line?
    Instead of YOURNEWPREFIX put something like 'site2' or whatever you want.

    Then, in PHPmyAdmin duplicate the wp_options table, and rename one of the them to be YOURNEWPREFIX_options, so if you chose 'site2', it would be 'site2_options'.

    Bingo. Edit the information in the 'site2_options' table to refelct the correct information for your second site and you will be on your way.

Topic Closed

This topic has been closed to new replies.

About this Topic