Multiple sites/domains with content all managed by single installation of WordPress

I’ve had an interesting request from a client, and subsequently spent a couple of hours looking into it. The crux of it is exactly as the title of this post suggests: they have 3 separate sites with unique domains, but the subject material & content for all three is ostensibly the same.

They would like to be able to manage a single pool of content from a single, central location, and for those changes to be echoed across the 3 sites.

Read More

For example, there is an Order Details page with an email address to enquire about back-catalogue items and a list of links to purchase stuff from. The client wants to be able to change that email address from info@ to sales@ and switch out the iTunes link for an Amazon link – and then for those changes to be updated on the Order Details page of each one of the three sites.

I’ve taken a look at WPMU; I hadn’t used it before, but I just did a quick installation and have been reading up on it for the last hour or so, but I don’t think it’s what we’re after, as each subdomain’s content is ‘siloed’ (as you’d expect).

I’ve also looked into services like InfiniteWP, which looks great and suggest that this kind of feature is ‘in the works’ (for a price), but obviously in the meantime involves switching between active sites to update posts & pages one site at a time.

So, does anyone know if this kind of thing is technically feasible, or if the client is asking for the moon on a stick?

Update: Client has just thrown a spanner in the works by suggesting that a single news post could be posted to one, two, or all three sites. Which makes things… interesting (read: headachey).

Related posts

Leave a Reply

1 comment

  1. This should be doable.

    First step would be pointing each domain to the same document root/install of WordPress.

    Next up, use WP_HOME and WP_SITEURL in wp-config.php that change based on $_SERVER['HTTP_HOST']. Example:

    <?php
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp');
    

    That should force your permalinks (at least the ones generated dynamically), enqueues, etc to work correctly.

    From there, I would create a metabox in the admin with some checkboxes for available domains. Each available post type should have this.

    On the front end, hook into pre_get_posts, look for the current domain as the meta key, change the query to only fetch posts for that domain.

    Quick example (untested, use with caution):

    <?php
    add_action('pre_get_posts', 'wpse70213_change_q');
    function wpse70213_change_q($query)
    {
        if(is_admin() || !$q->is_main_query())
            return;
    
        $key = 'wpse70213_host_'; // or whatever you want this to be
        $host = strtolower($_SERVER['HTTP_HOST']); // normalize http host
    
        // not sure if you can set meta_query like this...
        $q->set('meta_query', array(array(
            'key'   => $key . $host,
            'value' => 'on', // or whatever you use for "on" checkboxes
        )));
    }
    

    In short, it’s doable, but you’ll need to be in control of the entire WP installation.

    Other things to consider:

    • How do you deal with nav menus?
    • What about sidebars?
    • There will only be one, central taxonomy set for a given site — is that an issue?
    • How much overhead does using meta_query on every page add?
    • Users that don’t have any posts on one site will still have an author page on that site.
    • You’d have to invent a user management system that mimics multisite’s assignment of users to blogs if you need functionality like that.

    This is a really interesting idea. Might be good plugin material!