Home  >  Article  >  CMS Tutorial  >  Retargeting WordPress: Transferring Website from Multisite Network

Retargeting WordPress: Transferring Website from Multisite Network

王林
王林Original
2023-08-30 12:29:01890browse

Sometimes a site is already created in a WordPress multisite network but needs to be moved to its own single-site installation. There are several situations in which this may occur, including:

  • The site has grown too large to be included in the network.
  • This website needs its own IP address.
  • The website owner is changing providers or taking over full management of the website itself.

In some cases you may find that you can move a site out of multisite using a plugin or combination of plugins, but if this doesn't work you will need to move the relevant database tables. Moving a site out of a multisite network in this way is a tricky process because it involves isolating the database tables in the multisite database that are relevant to that specific site. But it's not impossible.

What do you need

To follow this tutorial you will need:

  • WordPress multisite installation with a subsite that you want to move to its own WordPress installation.
  • The second location you want to move your site to.

  • For manual moves, you will need an FTP client, a code editor, and access to phpMyAdmin.

Note: You cannot move the primary site out of a multisite network because the network will not workwithout it. If you do need to move your main site's content elsewhere, I recommend creating a copy and then replacing the original site's content with a dummy site. However, you won't be able to move the domain because it's also used by every other site in your network.

Use plugins to migrate sites out of multisite

If your website doesn’t have extensive configuration via plugins, themes, or website settings screens, you can successfully move it using the WordPress Importer plugin. If your website has widgets, you can copy their settings using the Widget Settings Importer/Exporter plugin.

However, if you added a lot of custom configurations using the settings or options screen or the theme customizer, none of these configurations will be copied. In this case, you need to move manually.

For full details on how to use these plugins to move your site, see my previous tutorial on moving a WordPress site using plugins. The process is exactly the same as moving a site from a multisite network to its own WordPress installation.

Manually migrate a site out of multisite

The site you are moving out of Multisite will contain three components that you need to copy from the Multisite network:

  • Theme and plugin files - you can copy these files or reinstall them in a new website
  • uploads — You can find these in the sites subdirectory at wp-content/uploads/sites
  • Database Tables - You don’t need all database tables, just the ones related to this website

Note: If your multisite network was created before WordPress 3.5, you will not have a sites folder. Instead, you will have a blogs.dir folder in wp-content that contains all the uploaded files for the subsite. This will give you a numbered folder for the site you want to migrate, which you can copy . I'll cover this in more detail below.

Do you really need a mobile website?

Before you begin, consider why you want to move your site. Is it just to change to a new domain name? If this is the case, then a free domain mapping plugin will allow you to give each site its own domain, and your visitors will never see the domain of your multisite network.

But if that’s not the only reason, keep reading!

Backup first

Before performing such operations, it is a good idea to back up your multisite installation. Use your favorite backup plugin, or if you prefer to work manually, use a combination of FTP and phpMyAdmin.

You will use this backup to copy relevant files to your new website and also give you peace of mind in case of any issues.

Find your site’s ID in a multisite network

Each site in a multisite network has its own unique numerical ID. This is used to identify folders in the wp-content/uploads/sites directory (or wp-content/blogs.dir if you have an older multisite network, see above ) and identify the site's database tables.

You can find this by going to Network Management > Sites and selecting the Edit option for the site you are using. The URL that WordPress directs you to will provide you with the ID of your website. The URL should be in the format http://mynetwork.com/wp-admin/network/site-info.php?id=XX.

XX is the ID of your site, and will be the name of the folder containing its files, and the prefix of its database table name.

p>

Export the table of the site from the network

Since you are only moving a subsite and not the entire installation, you do not need the contents of the entire database.

In PhpMyAdmin, click the Export tab. Then find the table related to the site you want to export. They will start with wp_XX_, where XX is your site's ID. An example is shown below.

重新定位 WordPress:从多站点网络传输网站

Select all tables related to your subsite and export them.

Note: WordPress Multisite stores all data related to web users in the wp_users and wp_usermeta tables: it does not create separate data for each site. If you have a lot of users on your site that you want to copy from the web, you may also want to export these tables, import them to the new site and edit the users in the admin screen to remove any non-existent users. Related to the new website. However, if your site only has one or two users, it will be easier to recreate the users on the new site. For more information about multisite and database tables, see our tutorial on WordPress databases and multisites.

Edit database table

Copy the sql file that was downloaded to your computer and give it a name (for example, add copy to its name). Open it in the code editor.

Edit link

Change all instances of a site domain in a multi-site network to their new single-site domain. For example, if your site is at http://network.com/mysite, change it to http://mysite.com. If your network uses subdomains, you will need to change all instances of http://mysite.network.com. If you do this, I recommend you also run check subdirectory versions just in case. Save your file.

Note: If your site is mapped to a domain that is not the one you are moving it to, you will also need to replace it with the new domain. Be very careful here and keep backups!

Edit table reference

The database tables in a new single-site installation will not have the site ID prefixed, so you need to delete them. In the sql file, replace all instances of wp_XX_ with wp_, where XX is your site ID. p>

Now save the sql file.

Install WordPress and create the database in the new location

In phpMyAdmin, create a new database in the location of your new site and install WordPress in the normal way.

Upload files to new website

Identify the plugins used by the subsite and install them into your new WordPress site via the Plugins screen or upload them from your backup of the old site.

Do the same with any themes your site uses - copy them from the backup to the wp-content/themes directory of your new standalone WordPress installation, or just reinstall them.

Copy upload content from old website to new website:

  • If the network was created after WordPress 3.5, it will contain a sites folder in wp-content/uploads. Find the subfolder that contains your site ID and upload its contents to the wp-content/uploads folder in your new site.
  • If you are on an older network and have a blogs.dir folder, that folder will also contain a folder containing your website ID. There will then be a subfolder named files. Copy the contents of the files folder to the wp-content/uploads folder in the new website.

Note: You may need to delete any folders WordPress created in the new uploads folder to avoid any conflicts.

After completing all this, activate all themes and plugins.

Import the table into the new database

Now that you have the theme and plugin installed, you need to import the database tables.

Delete existing table

Before uploading the table from the old website, you need to delete the duplicate table that WordPress added to the new website.

In phpMyAdmin, delete the following tables from the database:

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy

Screenshot showing my database with only these tables selected:

重新定位 WordPress:从多站点网络传输网站

Select them, click the Select: drop-down box, and select Delete. When prompted, click Start.

Note: Do not delete the <em>wp_usermeta</em> or <em>wp_users</em> table , unless you also choose to copy these tables from the network (see above).

Upload database table

Next upload your edited database:

  • Click to import the tag.
  • Click the Select File button.
  • Select the sql file you have edited, and then click Select or Confirm.
  • Click the Start button.
  • After some time (depending on the size of the database), you will see a message telling you that the upload completed successfully.

Final Steps

Clear your browser's cache. This avoids any issues you might encounter if your browser has cached content from an older website.

Now log in as the WordPress administrator of the remote site. If you move the users table, your login details will be the same as on the old site, but if you didn't, these details will be what you specified when you installed WordPress in the new location.

Visit the Permalinks screen and reopen the beautiful permalinks.

Check that all your links are working properly and widgets and plugins are functioning as they should. If not, you can fall back on the process and use backups where needed, or just set up plugins and widgets in your new site.

Removing a site from a multisite network

Once you are completely satisfied that everything is working properly, remove the site from the multisite installation. I recommend leaving it on for a week or so in case you notice anything that hasn't been moved. In the meantime, you can use a plugin or configure the old site's domain in CPanel to map to the new site.

Yo! It's a long and slightly complicated process, but you're done.

Summary

Moving a site from WordPress Multisite to its own installation is not something that can be done quickly or thoroughly, but it is possible and I have done it a few times. If you follow the steps above and make sure you have a backup in case anything goes wrong, you should find that it goes smoothly for you.

The above is the detailed content of Retargeting WordPress: Transferring Website from Multisite Network. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn