Generally, for the webmaster of a wordpress website, he will not easily change the domain name of his website. Because the domain name is equivalent to the ID number of a wordpress website. Users can find your website by using this domain name. Another reason is that if the domain name is changed, and if the WordPress website space is domestic, it will take a lot of time to re record the new domain name.
However, there are always some special circumstances. For example, our WordPress website was demoted by the search engine due to some illegal operations, and even no longer included our website. In this case, we may need to change the domain name of our wordpress website. At this time, another situation may occur: when inserting an article image, the image address written to the wordpress database may be an absolute path address, that is, the image address with the domain name (as shown below).
At this time, if the domain name of our wordpress website is changed, the image addresses of these absolute paths will not be opened in the browser after the original domain name is stopped. So, at this time, as the webmaster of WordPress, what should we do? There are only two methods. Either upload pictures again for each article, or modify the image address of the article on the WordPress website in batches - change the original domain name to the current new domain name.
Obviously, the first method - uploading pictures again for each article is not feasible. If the number of articles on our WordPress website is small, just a few or more than ten, it's easy to say. If our website has thousands of articles, even tens of thousands of articles, and the pictures are uploaded again one by one, isn't that to blame?
Therefore, the second method is our correct way. Then, the problem arises again. How to batch modify the domain name of the article image address of our WordPress website? The image address is stored in the wordpress database. Can we modify the address of the article image in batch through the operation of the wordpress database? The answer is yes.
Earlier, we introduced the phpmyadmin database management tool (of course, you can also use other database management tools to operate). Let's introduce how to use phpmyadmin to batch modify the image addresses of articles on the WordPress website.
Method 1: SQL code to batch modify the article image address.
Step 1: phpmyadmin logs in to your wordpress database.
If you have multiple websites on the same server, you may have multiple website databases after logging into phpmyadmin, as shown below:
Be sure to find the database of the WordPress website where you want to change the domain name. If you find it wrong, it will be terrible.
Step 2: Select the wp posts data table.
After finding your WordPress website database, click the "wp posts" data table on the left (as shown in the figure below). This table is the table used by WordPress to store article information. The main information of all articles on WordPress website is stored in this table.
Step 3: click "SQL" in the top menu;
Click the "SQL" menu in the above figure to enter the SQL statement interface, as shown below:
Step 4: Enter the SQL statement in the input box.
Enter the following SQL code in the input box with the red icon on the top, and then click the "Execute" button.
UPDATE wp_posts SET post_content=replace (post_content, old domain name, new domain name)
Method 2: Use the "Find and Replace" function to replace in batches.
Step 1: phpmyadmin enters the wp posts data table.
The method is the same as above, so I won't say much here.
Step 2: Click "Search" in the top menu to enter the search interface, as shown below:
Step 3: Click the "Find and Replace" button. Enter the interface as shown below:
Step 4: Enter "old domain name" in the "search" input box, and enter "your new domain name" in the "replace with" input box, and select post_content (article content) in the field. Then click the "Execute" button.
Through the above two methods, you can implement batch modification of article image addresses on the WordPress website. However, no matter which method you use to modify the domain name in the image address, you'd better back up the database of the WordPress website before modifying - in case of loss caused by modification failure. The same sentence: the modification is risky, and the operation should be careful.