Introduction
This is an article where the main focus is how to change URL of a WordPress-based web application manually in the post articles. Actually, there is a change on the server URL address. The effect is that the WordPress-based web application’s link reference is suddenly not working. Especially those links exist inside the post article of the WordPress-based web application. In case of the URL address which is retrieving from the WordPress-based web application, it is very easy to solve it. There is a place where the URL address of the running WordPress-based web application is the key to solve the URL change. So, normally if there is a change in the URL address of a WordPress-based web application, just change it by the following sequence steps :
-
Access the database of the WordPress-based web application.
-
First of all, check the database of that WordPress-based web application for the existence of a specific table. The table name can be vary. It actually depends on the initial installation setting of the WordPress-based web application. It is a table ends with the name of ‘options’ with the full name of ‘prefix_table_options’, where the ‘prefix_table_’ part vary from one environment to another. By default it goes with the name of ‘wp_options’.
-
Just execute the following query to change the URL master reference which the website is using as a reference :
UPDATE prefix_table_options SET option_value = replace(option_value,'http://www.myoldsites.com','https://www.mynewsites.com') WHERE option_name = 'home' OR option_name = 'siteurl';
In this context the ‘prefix_table_’ part name of the table can be vary depends on the initial installation setting. So, by default the query exist as follows :
UPDATE wp_options SET option_value = replace(option_value,'http://www.myoldsites.com','https://www.mynewsites.com') WHERE option_name = 'home' OR option_name = 'siteurl';
But that is not enough, it only change the URL address of the part where it actually get the URL address from the database configuration. But most of the page or post article where there is a hard-coded URL address, the above solution cannot solve the problem.
Solution
So, in order to change the manual link of URL address from the old one into a new one. Especially the one which exist in the post article. The following are the steps to achieve it :
-
Access the database of the WordPress-based web application.
-
Continue on the step, just check the database of that WordPress-based web application for the existence of a specific table. The table name can be vary. It actually depends on the initial installation setting of the WordPress-based web application. One of the tables ends with ‘posts’ with the column target of ‘post_content’ and ‘guid’. By default it goes with the name of ‘wp_posts’. The other table is the table ends with the name of ‘postmeta’ where by default it goes with the name of ‘wp_postmeta’.
-
The following is the query for replacing the manual link available in the post article. It will replace the old URL with the new one as follows :
UPDATE prefix_table_posts SET post_content = replace(post_content,'http://www.myoldsites.com','https://www.mynewsites.com'); UPDATE prefix_table_posts SET guid = replace(guid,'http://www.myoldsites.com','https://www.mynewsites.com'); UPDATE prefix_table_postmeta SET meta_value = replace(meta_value,'http://www.myoldsites.com','https://www.mynewsites.com');
So, using the default prefix name, the query will be as in the following execution :
UPDATE wp_posts SET post_content = replace(post_content,'http://www.myoldsites.com','https://www.mynewsites.com'); UPDATE wp_posts SET guid = replace(guid,'http://www.myoldsites.com','https://www.mynewsites.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.myoldsites.com','https://www.mynewsites.com');