When you import the database into the localhost, you’ll need to update the siteurl
and home
options from the wp_options
table. I’m guessing these values still have your old site’s URL. Change it to the URL you would enter into your browser in order to access the site on your localhost setup.
Also, the wp-config.php file will need to be updated with your localhost database’s name, username, password, and hostname. You’ll find these in the lines that look like this:
/** The name of the database for WordPress */
define('DB_NAME', 'your-old-database-name');
/** MySQL database username */
define('DB_USER', 'your-old-database-username');
/** MySQL database password */
define('DB_PASSWORD', 'your-old-database-password');
/** MySQL hostname */
define('DB_HOST', 'your-old-database-host');
Change all of the “your-old…” pieces to the appropriate values for your localhost database.
This should, at a minimum allow you to log-in to your site. The site may not display 100% correctly, though. For example, some images may have to be updated as they are likely referencing your old domain (i.e. https://youroldsite.com/wp-content/image-name.jpg needs to be updated to https://localhost/new-site/wp-content/image-name.jpg).
An easy way to fix this in bulk is to use the Better Search Replace plugin. Enter the old domain as the “find” string, and the new, localhost domain, as the “replace” string.
I’m hoping you also backed up the wp-content folder from your old site? This is where all the plugins, theme files, and images “live” on the site. If you did, you can swap out the backup copy of wp-content for the new site’s wp-content folder.