Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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!

share|improve this answer
    
Gah, this is an absolutely awesome answer, but I'm too newbed-up to upvote it! I had considered doing exactly as you suggested, which is using either a custom taxonomy or straighforward category match to determine which site picked up which news posts, but hadn't really gotten my head around the wider issue of actually getting those site managed and centrally-administrated. With regards to things like nav menus, sidebars, etc. - in this particular instance, they would be hard-coded, and only a single user/admin for updating the site(s), rather than a traditional WP blog. –  indextwo Oct 23 '12 at 16:43
1  
Honestly, this is a really cool idea. I might steal it and turn it into a plugin. :| –  chrisguitarguy Oct 23 '12 at 16:59
    
BAGSY THE PLUGIN FIRST IT WAS MY (client's) IDEA. I'll mention you guys in the PHP comments. Way down the bottom there. –  indextwo Oct 23 '12 at 17:50
    
Hm, if you had multiple pages sharing the same domain, would there be any way to designate one of them the home landing page for each domain, and the others with normal permalinks? –  Stephen May 21 at 10:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.