In WordPress multisite network admin, you can create site in Sites -> Add New with the following default fields:
- Site Title
- Site Address URL
- Site Language
- Admin email
This is how it looks like:
When you click the Add site button, WordPress core automatically assigns a blog ID to this site that is usually incremented from the last blog ID.
The problem: You cannot control and assign this blog ID when you create the subsite. There are instances where you need to re-create the new site with specific blog ID. This is typically used when restoring a subsite backup or migrating a subsite from another multisite or single installation.
There are other purpose as well where you need to create with specific blog ID (usability, or personal reasons).
Currently there is no code or straightforward WordPress API solution to do this.
There is an easy solution, when you create a site it allows you to assign specific blog ID to it.
- Install Prime Mover PRO (professional version) in your network admin plugins page. This is the PRO version of Prime Mover, the free version does not includes this feature.
- Once the plugin and license is activated, go to Network -> Sites , click “Add New” to create new site.
- Fill in all required fields when creating the site.
- Now the plugin adds a new field to let you assign a blog ID for your new site. This is how it looks like:
- Enter any blog ID that you would like to assign. In the above screenshot, it assigns 789 as the blog ID for the site to be created.
Limitations and Proper Usage
While it looks very easy and straightforward, please take note that this is still subject to some limitations that you need to be aware of (before using this solution):
- It will not use your assigned blog ID if its already used by other sites within the multisite. For example a site testxyz.test.com has a blog ID of 7. And you create a new site testabc.test.com with assigned blog ID of 7. This is not possible. The blog will still be created but not using 7 as blog ID (since its already used). The blog ID will be different (auto-assigned by WordPress). To prevent this issue, please double check first that the blog ID is unique ! This is because WordPress does not allow duplicated blog IDs.
- Please do not enter negative blog IDs, 0 or blog ID of 1. These are incorrect blog IDs that should not be used with multisite sub-sites.
- You are not required to enter blog ID every time you create a new site. This field is only OPTIONAL. If you do not enter a specific blog ID, you let WordPress auto-assign any blog ID for that site.
Verify if its working correctly
How do you know that the created site blog ID is correctly created? Please refer to these steps:
- Go to Network -> Sites -> All Sites.
- In the Search Sites search field. Enter the blog ID that you have specifically assigned.
- Click Search site button.
- If the site is found to exist, the blog ID is correctly assigned. (see example below):
- If the site is not found, WordPress must have auto-assign blog IDs to it and is not using your provided blog ID since its already duplicated (or found to exist). You can delete that site and re-create the site again with the fresh unique blog ID.
Questions ? Suggestions ?
Please drop by your questions by commenting below. If you have presale questions, please ask it here.
If you want to contact us personally, please do it here. Thanks !