Support » Themes and Templates » Multiple sites/themes using the same WP database?

  • Is it possible to use the same WP database but have mulitiple sites with different sets of links and pages to each? If so, how would I set this up?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Yeah, that’s precisely what the DB table prefix is for.

    During the DB configuration part of installation, specify the DB connection information for your current WP installation’s database. Then, change the field labeled table prefix or database prefix (can’t remember exactly what it’s called) to something other than the default “wp_” which is probably already being used by your existing WordPress install.

    This will install the new WP installation’s tables into the same DB with a different prefix before the table name, ie. newprefix_posts instead of wp_posts.

    I’ve also been thinking about this setup. But can you use the same tables for different installations? For example if you want to share users between two sites.

    Not right out of the box, nope. The two installs would be completely seperate.

    Search here in the forums for some hacks or related discussions on sharing users. It comes up every now and then, but I can’t recall any specifics.

    If all you’re wanting to do is have the same users on all your blogs, install your WP installations on the same DB as I explained above. Then, in wp-settings.php, search for $wpdb->users and $wpdb->usermeta. Replace the $table_prefix variable with the table prefix of the users table prefix of the blog with your users. It will probably be wp_ unless you changed it in your initial installation.

    Thanks akbigdog — but how would I begin to change this if the installation has already taken place? Where do I go to make these changes, in my PHP admin?

    You would have to edit the file wp-settings.php in a text editor i.e. vi and make those changes. Seems easy enough I just hope that will work. Thanks All for your help.

    The methods I described in my two posts above are contingent on installing the two blogs on the same database. What you suggest becomes very complicated very quickly if they are not installed using the same database.

    Okay, I have WordPress 2.1, and my wp-settings file has the following line:

    $wpdb->users = $wpdb->prefix . 'users';

    I don’t see $table_prefix. Admittedly, I’m a PHP noob, so I may be missing something.

    $table_prefix is not used any more $wpdb->prefix is the same thing just the new way of getting this information.

    So replace $wpdb->prefix with the prefix you used in your other blog. example:
    $wpdb->users = 'wp_' . 'users';
    If you used the default wp_ in your first blog.

    I’d like to do something similar, but instead of sharing users, I only want to share posts.

    Ultimately, I want each site to have its own theme, options, users, etc. but I want all sites to share the same posts.


    Well, that would be duplicate content and the search engines wouldn’t like it.
    You will have to ask about it in a ‘splog support’ forum 🙂

    @moshu: Luckily, I’m not producing content for search engines. I’m producing it for clients – and it’s not for spamming purposes. Consider using wordpress for something like this – (this company writes content for multiple clients who, in turn, deliver it to their respective constituents). 🙂

    I think I found the answer to my own question thanks to akbigdog’s comments above. I would like some confirmation though…

    $wpdb->posts = $wpdb->prefix . 'posts';

    should be changed to

    $wpdb->posts = 'newprefix_' . 'posts';

    in wp-settings.php for each individual wp install.

    Is this correct?

    Seems I want to do the same thing. One database with multiple sites pulling content from it. I was thinking of giving multiple categories to my posts, depending on what site needs to display the news. Did you guys pull this off? Was it easy?

    I’d like to know if I should use WordPress for this. Been looking for a long time now to find the correct tool to do this.

    Many thanx,


    Actually, it was pretty easy DE. You just have to change your table prefixes in the wp-settings.php file like I mentioned above.

    I’ve not yet tried using different categories for different sites but I know it will work. You’ll just have to force your templates from each of the sites to read only posts in specific categories.

    Hope this helps.

    Thanx Ryan.

    I’ll give WordPress a try then ^_^

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Multiple sites/themes using the same WP database?’ is closed to new replies.