Support » Plugins » Hacks » Share certain tables across 2 installs

  • I want to use one set of tables, which is filled through an xml-feed to populate two almost identical installs, one in root, one in a subfolder. It has to be a multilanguage solution, where wpml simply won’t work. The site is managed through one admin, the other one is hardly used. There will be no manual posts or pages made, so no crossposting is expected.

    I found this old post, but found it outdated. Anyone out there who is able to enlighten me how this can be coded in 3.3 of 3.3.1?


    Nevermind, I think I found it thanks top this site :
    (link outdated)

    Down in the comments they refer to more modern installs. I did this:

    Edit the wp-db.php file in the wp-includes directory.
    In the function set_prefix($prefix) section

    After :

    foreach ( $this->tables as $table )
    $this->$table = $this->prefix . $table;

    Added :
    $this->options = ‘wp_’ . ‘options’;

    Or whatever your new prefix is. Testing now, I’ll write again if I experience any issues. This is a case of spending 4 hours a few nights ago, and going around in circles. Then after only 20 minutes of trying tonight, getting it working. The benefits of rest apparently.

    Here is the rest of the code you would need in addition to the ‘options’ for all of the tables in wordpress.

    $this->posts = ‘wp_’ . ‘posts’;
    $this->categories = ‘wp_’ . ‘categories’;
    $this->options = ‘wp2_’ . ‘options’;
    $this->links = ‘wp2_’ . ‘links’;
    $this->postmeta = ‘wp_’ . ‘postmeta’;
    $this->terms = ‘wp_’ . ‘terms’;
    $this->term_taxonomy = ‘wp_’ . ‘term_taxonomy’;
    $this->term_relationships = ‘wp_’ . ‘term_relationships’;

  • The topic ‘Share certain tables across 2 installs’ is closed to new replies.