WordPress.org

Ready to get started?Download WordPress

Forums

Multiple sites/themes using the same WP database? (16 posts)

  1. smk2004
    Member
    Posted 7 years ago #

    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?

  2. Jon Bourne
    Member
    Posted 7 years ago #

    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.

  3. h8dk97
    Member
    Posted 7 years ago #

    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.

  4. Chris_K
    Member
    Posted 7 years ago #

    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.

  5. Jon Bourne
    Member
    Posted 7 years ago #

    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.

  6. smk2004
    Member
    Posted 7 years ago #

    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?

  7. h8dk97
    Member
    Posted 7 years ago #

    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.

  8. Jon Bourne
    Member
    Posted 7 years ago #

    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.

  9. noxdineen
    Member
    Posted 7 years ago #

    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.

  10. linuss
    Member
    Posted 7 years ago #

    $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.

  11. stuboo
    Member
    Posted 7 years ago #

    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.

    Thanks,
    Ryan

  12. moshu
    Member
    Posted 7 years ago #

    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 :)

  13. stuboo
    Member
    Posted 7 years ago #

    @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 - http://rrnewkirk.com/donorweb.html (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?

  14. DE
    Member
    Posted 7 years ago #

    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,

    DE

  15. stuboo
    Member
    Posted 7 years ago #

    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.
    Ryan

  16. DE
    Member
    Posted 7 years ago #

    Thanx Ryan.

    I'll give WordPress a try then ^_^

Topic Closed

This topic has been closed to new replies.

About this Topic