最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Multiple WordPress sites with different theme and plugin sharing the same content

matteradmin9PV0评论

I want run Multiple Wordpress websites with different theme and plugin using one database where the content remains the same in all websites.

1- site - Main site

2- siteb - Should use site database except for the theme & plugin

3- sitec - Should use site database except for the theme & plugin

Is there any way this can be done?

I want run Multiple Wordpress websites with different theme and plugin using one database where the content remains the same in all websites.

1- site - Main site

2- siteb - Should use site database except for the theme & plugin

3- sitec - Should use site database except for the theme & plugin

Is there any way this can be done?

Share Improve this question edited Dec 13, 2018 at 7:11 F.A asked Dec 12, 2018 at 19:25 F.AF.A 255 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This is not really a "multisite" case, as it's really just the one site content with a single database.

What you could do is detect when the subsite hostname is being used, probably by matching $_SERVER['HTTP_HOST'] in a must-use plugin... (if you don't create the subsites explicitly, your domain setup would need to allow "wildcard" subdomains.)

So that for each subdomain match, you can filter the active_plugins and stylesheet options via the option_{$key} filters which are used in get_option when the site is loading... eg.

add_filter('option_active_plugins', 'get_subsite_active_plugins');
function check_subsite_active_plugins($plugins) {
    if (strpos($_SERVER['HTTP_HOST'], '1.site') === 0) {
        $plugins = array('hello-dolly.php');
    }
    return $plugins;
}

However, you need to remember that if any changes are made to the database by a plugin or theme on any of the sites, it will affect all the sites. It some cases this might cause instability, but it is really hard to say depending on the plugins/themes.

Note there are some solutions out there already for using multiple themes, but nothing I know of specifically for having different plugin configurations like this.

Be aware also, there may be SEO ramifications to having "duplicate" content across subdomains, but there may be some way around that.

Post a comment

comment list (0)

  1. No comments so far