When migrating a WordPress site you may notice that images still point back to the previous server (or localhost). Even if you go into the Settings or database and change the site_url you’ll still find post images pointing back to their original location. You may also notice that certain theme and plugin setting retain the old absolute URLs as well.
I like to handle this by doing a search and replace in the database using WP-CLI (WordPress Command Line). The command looks like this:
(run this from within the WordPress directory)
There are also plugins that can do this for you if you’re not into the command-line. Google “wordpress database search replace” and find a popular, well rated one.
Understanding how a programming language works is a surefire way to be a better developer. Read more.