Forums

Share certain tables of a WP database over 2 domains (5 posts)

  1. yarray
    Member
    Posted 2 years ago #

    Is there a plugin that would allow you to share certain tables in a database in order to have the same posts on each installation via different domains.

    Example i would like to run 2 wordpress blogs with the same content but with different layouts, and different plugins. I would need to share the posts but would need to keep 2 separate databases for the blogs internal settings like themes, and comments.

  2. songdogtech
    Member
    Posted 2 years ago #

    This thread should be helpful; it's not a plugin but some code to work with.

  3. yarray
    Member
    Posted 2 years ago #

    found the solution here

    QUOTED FROM http://wordpress.org/support/topic/312547?replies=2

    Nevermind, I think I found it thanks top this site :
    http://www.wiseontech.com/hack/wordpress-hacking-multiple-blogs-on-one-set-of-tables-2

    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';
  4. songdogtech
    Member
    Posted 2 years ago #

    Looks interesting. You original question was sharing a DB across different domains rather than a multiple WP install on one domain and DB. Hope that works for it; post back your results for others to read.

  5. yarray
    Member
    Posted 2 years ago #

    yea that code is for sharing a DB across different domains

    it shares everything except the
    options links users and usermeta tables

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags