Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Consolidating several blogs into a single multisite instance - we have 2 sets of blogs - active and archived.

What's the best way of adding /archive/ to the URLs of the archived blogs?

So, as an example:

  • An active blog would be accessed via
  • An archived blog would be accessed via

I've taken a look at a couple of domain mapping plugins (including the WPMU Dev) one, but I don't think they do what I need.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

In order to do partition your blogs like this you're going to need to write a custom plugin similar to the WordPress MU Domain Mapping plugin. Here's how your plugin needs to work.

  1. Create a sunrise.php file for your plugin, and properly define('SUNRISE',true); in your wp-config.php file.
  2. Create a table which maps the tuples {blog_slug, blog_id, is_archived}

In sunrise.php perform the following logic:

$access_url = $_SERVER[ 'REQUEST_URI' ];
$on_archive = false;
$slug = "";
$parts = explode('/',$access_url);
for($i = 0; $i < count($parts); ++$i) {
   if(strpos($parts[i],"") !== false) {
      if($parts[i + 1] == "archived") {
         $on_archive = true;
         $slug = $parts[i+2]; // TODO: Index checking
      } else
         $slug = $parts[i + 1];

$blog_id = $wpdb->get_var("SELECT blog_id FROM YOURTABLE WHERE blog_name=$slug ...");
if($blog_id && $on_archive) {
   $current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$blog_id' LIMIT 1");
   $current_blog->path = '/archived';
   $site_id = $current_blog->site_id;

   $current_site = $wpdb->get_row( "SELECT * from {$wpdb->site} WHERE id = '{$current_blog->site_id}' LIMIT 0,1" );
   $current_site->blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
} else {
   // Things went wrong, redirect to the home page, or something

Finally, populate the fields of your table so that it knows which blogs are "archived". In production you'd probably want to add some array safety checks, as well as checking that if "blog_a" is archived, then visiting redirects to All of these things can be handled in the sunrise file.

share|improve this answer
thanks - i'll be able to test this later today or tomorrow and give some feedback – anu Apr 27 '11 at 8:38

Your Answer


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.