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!