Okay, here's the site I'm working on:
http://www.mcguireprogramme.se/wordpress/
http://www.mcguireprogramme.dk/wordpress/
http://www.mcguireprogramme.no/wordpress/
You can switch between these by using the links in the blogroll.
The selection of pages should depend on which of these domains you choose (some pages should be visible on more than one domain). So I wrote this fine plugin, to filter the pages list depending on which top-level domain is used:
<?php
/*
Plugin Name: Filter Page List
Version: 0.0.1
Plugin URI:
Description: Filter which pages are shown in the sidebar based on the 'domain' custom field.
Author: Gustaf Liljegren
Author URI:
*/function filter_pages($pages)
{
// Get current top-level domain
$host = $_SERVER["HTTP_HOST"];
$parts = explode('.', $host);
$tld = end($parts);// Get all pages
$myQuery = new WP_Query();
$myQuery->query('post_type=page');
$pagesToShow = array();
while ($myQuery->have_posts())
{
$myQuery->the_post();
global $post;// Get the 'domain' meta value
$domain = get_post_meta($post->ID, 'domain', false);// If there is no 'domain' key
if ($domain == NULL)
{
// Show this page
$pagesToShow[] = $post->ID;
}
// If there is a 'domain' key
else
{
// Loop through 'domain' values
foreach ($domain as $d)
{
// If there's a value matching the current top-level domain
if ($d == $tld)
{
// Show this page
$pagesToShow[] = $post->ID;
}
}
}
}// Return result
return $pagesToShow;
}add_filter('wp_list_pages_excludes', 'filter_pages');
?>
As you can see, it uses the wp_list_pages_excludes filter. I've also added the plugin code to the sidebar, just under the page list, so you can see what it returns. It shows that the plugin makes the right selection for each domain.
But when the plugin is activated, in wp_list_pages(), something weird happens. I get another selection for each domain! So there's something evil happening in wp_list_pages(), and I've no idea how to figure out what it is.