Website relocation is no stranger to website builders, and WordPress relocation is no exception. When we move our WordPress blog or move, we sometimes need to replace the image path in WordPress articles to solve the problem of not displaying images. So how to solve this problem? WordPress tutorial network to teach you how to batch replace the image path!
Why do you replace image paths in batches
1. Change website domain name
Many websites have randomly selected a website domain name at the initial stage of construction. When updating articles, images are uploaded with their own website domain name in many cases. Therefore, once the domain name is changed, the image link address will become invalid.
2. The address of the external link graph bed is invalid
Sometimes, in order to save website space, or update articles without too much consideration, a unified external map bed chain is used, such as the secondary domain name of Qiniu cloud storage. Once the external link of the map bed fails, it may be burglarized, or the secondary domain name may be changed, then the link address of the image will become invalid.
3. The picture address is invalid for other reasons
In the above three cases, if you want to change the image link address of an article, do not modify it in batches, but manually modify it. It doesn't matter if there are only ten or eight articles. Otherwise, it will be difficult to update the image address.
Batch replacement of database commands
Update the image link addresses in all articles through MySQL operation command statements.
It should be noted that the novice must back up the database before operation, so as to avoid mistakes in operation. How to back up a database? I will not go into details about searching related tutorials on the Internet.
Log in to your own database management background, log in to the PHPMyadmin database management software, and log in to the background to select the corresponding database wp_posts table, as shown in the following figure:
Execute the SQL command line operation and enter the command line UPDATE wp_posts SET post_content=REPLACE (post_content, 'old web address',' new web address');? Examples are as follows:
UPDATE wp_posts SET post_content=REPLACE (post_content, 'www. your domain name. com/wp content/uploads',' imgcdn. sense. com ');
UPDATE statement command description
UPDATE table name SET field=REPLACE (field, 'content to be replaced', 'replacement value');
Quotation marks are not required for table names and field names, but for the content to be replaced and the value to be replaced, because they are string types, attention should be paid here.
Finally, the batch replacement of pictures in WordPress articles is completed.