fervor [>]CODING & CURIOSITY
FERVOR LEARNING SYSTEMTUTORIALS
← WordPress

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

2. Export the Existing Site

  1. 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.
  2. 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 .wpress file.
    • Once the export is complete, click Download to save the file to your computer.

3. Set Up the Blank WordPress Site

  1. Install WordPress:

    • Set up a blank WordPress installation on your local server or hosting environment as usual.
  2. 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

  1. Import the .wpress File:

    • Go to All-in-One WP Migration > Import in the admin menu.
    • Click on Import From and choose File.
    • Upload the .wpress file you exported earlier.
    • Wait for the plugin to process the import. This might take a few minutes depending on the file size.
  2. Overwrite Confirmation:

    • When prompted, confirm that you want to overwrite the existing site.

5. Final Steps

  1. Save Permalinks:

    • After the import is complete, go to Settings > Permalinks in the WordPress dashboard.
    • Click Save Changes to regenerate the .htaccess file.
  2. 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 .wpress file 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

  1. Prerequisites
  2. Setting Up a Blank WordPress Installation
  3. Exporting the Existing Site’s Files and Database
  4. Importing Files to the New WordPress Setup
  5. Importing the Database
  6. Configuring wp-config.php
  7. Updating Site URLs
  8. Finalizing the Import
  9. Troubleshooting Common Issues
  10. 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

  1. Download WordPress:

  2. Extract and Move Files:

    • Unzip the downloaded WordPress package.
    • Move the extracted files to your local server’s htdocs directory (for MAMP) or the appropriate directory for your server environment.
    • Rename the folder to your desired project name, e.g., imported-site.
  3. 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.
  4. 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)
    • Complete the installation by providing site details and logging into the new WordPress admin dashboard.

Exporting the Existing Site’s Files and Database

Exporting Files

  1. 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.
  2. Download the Files:

    • Navigate to the root directory of the WordPress installation (where wp-config.php resides).
    • 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.

Exporting the Database

  1. Access phpMyAdmin:

    • Log in to phpMyAdmin via your hosting control panel or directly if available.
  2. Select the Database:

    • Choose the database associated with the existing WordPress site from the left sidebar.
  3. 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 .sql file to your local machine.

Importing Files to the New WordPress Setup

  1. Backup Current Files (Optional but Recommended):

    • Before overwriting, consider backing up the blank WordPress installation’s files in case you need to revert.
  2. 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-site directory, overwriting existing files.
  3. Ensure Correct File Permissions:

    • Verify that the file permissions are correctly set, especially for wp-content and its subdirectories. Typically:
      • Folders: 755
      • Files: 644

Importing the Database

  1. Access Local phpMyAdmin:

    • Navigate to http://localhost:8888/phpMyAdmin/.
  2. Select the New Database:

    • Click on the imported_site_db database you created earlier.
  3. Import the .sql File:

    • Click on the Import tab.
    • Click Choose File and select the .sql file exported from the existing site.
    • Ensure the format is set to SQL.
    • Click Go to start the import process.
  4. 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

  1. Locate wp-config.php:

    • In your imported-site directory, find the wp-config.php file.
  2. Edit Database Credentials:

    • Open wp-config.php in 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.
  3. 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.php with 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

  1. Access phpMyAdmin:

    • Navigate to http://localhost:8888/phpMyAdmin/.
  2. Select the Database:

    • Choose imported_site_db.
  3. Edit wp_options Table:

    • Click on the wp_options table.
    • Locate the siteurl and home rows (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.

Method 2: Using SQL Queries

  1. Access phpMyAdmin and Select Database:

    • Navigate to imported_site_db.
  2. Go to the SQL Tab:

    • Click on the SQL tab to run custom queries.
  3. 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:

  1. Navigate to Your WordPress Directory:

    cd path/to/imported-site
    
  2. 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.

Finalizing the Import

  1. Clear Caches:

    • If you use caching plugins, clear all caches to ensure changes take effect.
  2. Update Permalinks:

    • Log in to the local WordPress admin dashboard.
    • Navigate to Settings > Permalinks.
    • Click Save Changes without altering anything to regenerate the .htaccess file.
  3. Check Media Links:

    • Ensure that media files are correctly linked. If images are missing, verify the wp-content/uploads/ directory.
  4. 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.log file for errors.

2. Database Connection Errors

  • Cause: Incorrect database credentials.
  • Solution:
    • Double-check the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST values in wp-config.php.
    • Ensure the local database exists and the user has the necessary privileges.
  • Cause: Incorrect site URLs or missing files.
  • Solution:
    • Verify that siteurl and home are correctly set in the wp_options table.
    • Ensure all files, especially in wp-content/uploads/, are properly imported.
  • Cause: Incorrect .htaccess configuration.
  • Solution:
    • Regenerate permalinks by saving the Permalinks settings.
    • Ensure that the .htaccess file 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 to plugins-deactivated.
    • Switch to a default theme like Twenty Twenty-One by renaming your current theme’s folder in wp-content/themes/.

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!

Keep your curiosity going.Explore more WordPress →
287 TUTORIALS · 22 TOPICSREADY