It’s a very common issue when migrating to a different domain. Try one of the two options:
1. Backend: execute a SQL query
Go into your database (phpMyAdmin) and execute the following SQL query:
UPDATE wp_options SET option_value = replace(option_value, 'OLD_URL', 'NEW_URL') WHERE option_name="home" OR option_name="siteurl";
UPDATE wp_posts SET guid = replace(guid, 'OLD_URL','NEW_URL');
UPDATE wp_posts SET post_content = replace(post_content, 'OLD_URL', 'NEW_URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'OLD_URL','NEW_URL');
OLD_URL
will be replaced withhttp://demo.example.com
NEW_URL
will be replaced withhttp://www.example.com
This will cover the siteurl
, home
, and all of your content on your website that is linking to the old URL.
2. Frontend: use the Search & Replace plugin
A more user-friendly approach is to use the Search & Replace plugin to easily replace all tables that contain your old URL. The process is easy to use and you can preview what tables and rows will be affected before applying those changes.
Forewarning
Before applying any changes, I think it goes without saying to always make a backup of your database in the event something goes wrong.