WordPress / 9 MIN READ
WP Import Site
How to import an existing site into a blank WordPress setup
From the original Fervor library. Examples may use older package versions.
Quick and Easy Guide: Importing a WordPress Site with a Plugin
If you’re looking for the fastest way to import a WordPress site into a blank setup, using a plugin is the simplest option. Here’s how you can do it:
Step-by-Step Instructions
1. Install a Migration Plugin
- The most popular and user-friendly migration plugins are:
- For this guide, we’ll use All-in-One WP Migration.
2. Export the Existing Site
-
Install All-in-One WP Migration on the Existing Site:
- Log in to the WordPress admin dashboard of your existing site.
- Navigate to Plugins > Add New.
- Search for “All-in-One WP Migration.”
- Click Install Now and then Activate.
-
Export the Site:
- Go to All-in-One WP Migration > Export in the admin menu.
- Click on Export To and choose File.
- The plugin will package your site into a downloadable
.wpressfile. - Once the export is complete, click Download to save the file to your computer.
3. Set Up the Blank WordPress Site
-
Install WordPress:
- Set up a blank WordPress installation on your local server or hosting environment as usual.
-
Install All-in-One WP Migration on the Blank Site:
- Log in to the new WordPress dashboard.
- Navigate to Plugins > Add New.
- Search for “All-in-One WP Migration.”
- Click Install Now and then Activate.
4. Import the Site
-
Import the
.wpressFile:- Go to All-in-One WP Migration > Import in the admin menu.
- Click on Import From and choose File.
- Upload the
.wpressfile you exported earlier. - Wait for the plugin to process the import. This might take a few minutes depending on the file size.
-
Overwrite Confirmation:
- When prompted, confirm that you want to overwrite the existing site.
5. Final Steps
-
Save Permalinks:
- After the import is complete, go to Settings > Permalinks in the WordPress dashboard.
- Click Save Changes to regenerate the
.htaccessfile.
-
Verify the Site:
- Browse the site to ensure everything works correctly.
- Check pages, posts, media, and plugins to confirm a successful import.
Advantages of Using a Plugin
- No Technical Knowledge Required: The plugin handles files, database, and configuration for you.
- Fast and Reliable: Importing a
.wpressfile is quick and easy. - Perfect for Beginners: You don’t need to deal with FTP, databases, or file permissions.
Conclusion
Using a migration plugin like All-in-One WP Migration is the easiest way to import a WordPress site into a blank setup. This method eliminates the need for manual database imports and file transfers, saving you time and effort.
Step-by-Step Tutorial: Importing an Existing Site into a Blank WordPress Setup (without Plugin)
Whether you’re migrating your website to a new server, setting up a staging environment, or simply creating a local copy for development, importing an existing site into a blank WordPress setup is a common task. This comprehensive guide will walk you through the entire process, ensuring a smooth and error-free migration.
Table of Contents
- Prerequisites
- Setting Up a Blank WordPress Installation
- Exporting the Existing Site’s Files and Database
- Importing Files to the New WordPress Setup
- Importing the Database
- Configuring
wp-config.php - Updating Site URLs
- Finalizing the Import
- Troubleshooting Common Issues
- Conclusion
Prerequisites
Before you begin, ensure you have the following:
-
Access to the Existing Site:
- FTP/SFTP credentials or file manager access.
- Access to the site’s database via phpMyAdmin or similar tool.
-
A Local Server Environment:
- Tools like MAMP, XAMPP, or Local by Flywheel installed.
-
Blank WordPress Installation:
- A fresh WordPress setup ready to receive the imported site.
-
Tools:
- FileZilla or another FTP client (if transferring files via FTP).
- phpMyAdmin for database management.
- Text Editor (e.g., VSCode) for editing configuration files.
Setting Up a Blank WordPress Installation
-
Download WordPress:
- Visit the WordPress.org download page and download the latest version.
-
Extract and Move Files:
- Unzip the downloaded WordPress package.
- Move the extracted files to your local server’s
htdocsdirectory (for MAMP) or the appropriate directory for your server environment. - Rename the folder to your desired project name, e.g.,
imported-site.
-
Create a New Database:
- Open your local server’s phpMyAdmin interface by navigating to
http://localhost:8888/phpMyAdmin/(adjust the port if necessary). - Click on the Databases tab.
- Enter a database name (e.g.,
imported_site_db) and click Create.
- Open your local server’s phpMyAdmin interface by navigating to
-
Install WordPress:
- Navigate to
http://localhost:8888/imported-site/in your browser. - Follow the WordPress installation wizard:
- Database Name:
imported_site_db - Username:
root(default for MAMP) - Password:
root(default for MAMP) - Database Host:
localhost - Table Prefix:
wp_(default)
- Database Name:
- Complete the installation by providing site details and logging into the new WordPress admin dashboard.
- Navigate to
Exporting the Existing Site’s Files and Database
Exporting Files
-
Access the Existing Site’s Files:
- Use an FTP client like FileZilla or your hosting provider’s file manager to access the site’s files.
-
Download the Files:
- Navigate to the root directory of the WordPress installation (where
wp-config.phpresides). - Download all files and folders to your local machine. This typically includes:
wp-admin/wp-includes/wp-content/- Core WordPress files like
wp-config.php,.htaccess, etc.
- Navigate to the root directory of the WordPress installation (where
Exporting the Database
-
Access phpMyAdmin:
- Log in to phpMyAdmin via your hosting control panel or directly if available.
-
Select the Database:
- Choose the database associated with the existing WordPress site from the left sidebar.
-
Export the Database:
- Click on the Export tab.
- Choose the Quick export method.
- Ensure the format is set to SQL.
- Click Go to download the
.sqlfile to your local machine.
Importing Files to the New WordPress Setup
-
Backup Current Files (Optional but Recommended):
- Before overwriting, consider backing up the blank WordPress installation’s files in case you need to revert.
-
Transfer Files:
- Replace the blank WordPress files with the files from the existing site:
- Copy all files and folders from the downloaded existing site to the
imported-sitedirectory, overwriting existing files.
- Copy all files and folders from the downloaded existing site to the
- Replace the blank WordPress files with the files from the existing site:
-
Ensure Correct File Permissions:
- Verify that the file permissions are correctly set, especially for
wp-contentand its subdirectories. Typically:- Folders:
755 - Files:
644
- Folders:
- Verify that the file permissions are correctly set, especially for
Importing the Database
-
Access Local phpMyAdmin:
- Navigate to
http://localhost:8888/phpMyAdmin/.
- Navigate to
-
Select the New Database:
- Click on the
imported_site_dbdatabase you created earlier.
- Click on the
-
Import the
.sqlFile:- Click on the Import tab.
- Click Choose File and select the
.sqlfile exported from the existing site. - Ensure the format is set to SQL.
- Click Go to start the import process.
-
Verify Import Success:
- Once the import is complete, you should see a success message.
- Check the database tables to ensure they are populated.
Configuring wp-config.php
-
Locate
wp-config.php:- In your
imported-sitedirectory, find thewp-config.phpfile.
- In your
-
Edit Database Credentials:
- Open
wp-config.phpin your text editor. - Update the following lines to match your local database settings:
define('DB_NAME', 'imported_site_db'); define('DB_USER', 'root'); define('DB_PASSWORD', 'root'); define('DB_HOST', 'localhost'); - Save the changes.
- Open
-
Set Unique Authentication Keys:
- It’s good practice to update the authentication keys and salts for security.
- Visit the WordPress Secret Key Generator to generate new keys.
- Replace the existing keys in
wp-config.phpwith the newly generated ones.
Updating Site URLs
After importing, the site URLs in the database still point to the live site. You need to update them to reflect the local environment.
Method 1: Using phpMyAdmin
-
Access phpMyAdmin:
- Navigate to
http://localhost:8888/phpMyAdmin/.
- Navigate to
-
Select the Database:
- Choose
imported_site_db.
- Choose
-
Edit
wp_optionsTable:- Click on the
wp_optionstable. - Locate the
siteurlandhomerows (usually the first two entries). - Click Edit next to each and update the URL to
http://localhost:8888/imported-site(adjust the path if different). - Save the changes.
- Click on the
Method 2: Using SQL Queries
-
Access phpMyAdmin and Select Database:
- Navigate to
imported_site_db.
- Navigate to
-
Go to the SQL Tab:
- Click on the SQL tab to run custom queries.
-
Run the Following Queries:
UPDATE wp_options SET option_value = 'http://localhost:8888/imported-site' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://localhost:8888/imported-site' WHERE option_name = 'home';- Click Go to execute the queries.
Method 3: Using wp-cli (Advanced)
If you have wp-cli installed, you can update URLs via the command line:
-
Navigate to Your WordPress Directory:
cd path/to/imported-site -
Run the Search and Replace Command:
wp search-replace 'https://www.livesite.com' 'http://localhost:8888/imported-site' --skip-columns=guid- Replace
'https://www.livesite.com'with your actual live site URL.
- Replace
Finalizing the Import
-
Clear Caches:
- If you use caching plugins, clear all caches to ensure changes take effect.
-
Update Permalinks:
- Log in to the local WordPress admin dashboard.
- Navigate to Settings > Permalinks.
- Click Save Changes without altering anything to regenerate the
.htaccessfile.
-
Check Media Links:
- Ensure that media files are correctly linked. If images are missing, verify the
wp-content/uploads/directory.
- Ensure that media files are correctly linked. If images are missing, verify the
-
Test the Site:
- Browse through the site to ensure all pages, posts, and functionalities work as expected.
Troubleshooting Common Issues
1. White Screen of Death (WSOD)
- Cause: PHP errors or memory limits.
- Solution:
- Enable debugging by adding the following to
wp-config.php:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); - Check the
wp-content/debug.logfile for errors.
- Enable debugging by adding the following to
2. Database Connection Errors
- Cause: Incorrect database credentials.
- Solution:
- Double-check the
DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTvalues inwp-config.php. - Ensure the local database exists and the user has the necessary privileges.
- Double-check the
3. Broken Links or Missing Images
- Cause: Incorrect site URLs or missing files.
- Solution:
- Verify that
siteurlandhomeare correctly set in thewp_optionstable. - Ensure all files, especially in
wp-content/uploads/, are properly imported.
- Verify that
4. Permalink Issues
- Cause: Incorrect
.htaccessconfiguration. - Solution:
- Regenerate permalinks by saving the Permalinks settings.
- Ensure that the
.htaccessfile is writable by WordPress.
5. Plugin or Theme Conflicts
- Cause: Incompatible plugins or themes.
- Solution:
- Temporarily deactivate all plugins by renaming the
wp-content/plugins/folder toplugins-deactivated. - Switch to a default theme like Twenty Twenty-One by renaming your current theme’s folder in
wp-content/themes/.
- Temporarily deactivate all plugins by renaming the
Conclusion
Importing an existing site into a blank WordPress setup involves transferring both files and the database, then configuring the new environment to match the original site. By following this step-by-step tutorial, you can efficiently migrate your WordPress site for development, staging, or backup purposes.
Key Takeaways:
- Backup First: Always back up both files and the database before making changes.
- Attention to Detail: Ensure all URLs and configurations are correctly updated to reflect the new environment.
- Test Thoroughly: After import, thoroughly test the site to catch and resolve any issues early.
With these steps, you should be well-equipped to handle WordPress site imports confidently. Happy migrating!