Changing a site number in WP multisite

Reset a WP network after site deletion so the next site will occupy the next highest number:

You can change the id of the next site created by running the following SQL query where “x” is the site # you wish to create. If that number already exists then it will check for the largest # and create a new site in the next number. It actually doesn’t allow you to go back if you have a range of missing sites like 30-40 if you have a larger number in the database so it really only allows you to reset to largest available number if you delete the site in the largest site id and want to replace it with one in the same ID again:

ALTER TABLE wp_blogs AUTO_INCREMENT = X

Change the ID of a currently active site to another ID without messing stuff up:

  1. In “wp_blogs” table change only “blog_id” field to new number
  2. Change all current tables to new number (i.e. changing “wp_x” to new “wp_y” for all)
  3. Change where site is directed to in domain mapping, “/wp-admin/network/settings.php?page=dm_admin_page”
  4. In new “wp_y_options” table where “y” is the new number of your new site, find the options named “wp_x_user_roles” where “x” is the number of your old site and change this to “y” so user roles are assigned properly.  <-Find this value!!!
  5. Change where person is assigned in /wp-admin/network/users.php … it will only work if you’ve gone through the first few steps.
  6. Change image directory to new number in “/uploads/sites/y/” if you don’t have a custom directory structure here.