Home  >  Article  >  CMS Tutorial  >  How to batch replace custom column values ​​in WordPress

How to batch replace custom column values ​​in WordPress

藏色散人
藏色散人forward
2020-02-05 15:52:202999browse

The following tutorial column of WordPress will introduce to you how to batch replace WordPress custom column values. I hope it will be helpful to friends in need!

How to batch replace custom column values ​​in WordPress

Add the following code to the current theme function template functions.php Finally:

global $wpdb;
$wpdb->query("UPDATE wp_postmeta SET meta_value = replace( meta_value, 'https://www.baidu.com/','https://down.baidu.com/')");

The above example is suitable for modifying only the domain name in the link address, not Modify the link behind the domain name.

For example: https://www.baidu.com/2020/01/file.zip

is replaced with: https://down.baidu.com/2020/01/file. zip

Others can be deduced by analogy.

After adding the code, refresh the web page and the replacement is completed.

Please back up your data before operation, just in case!

After replacement, please remove the above code.

The above is the detailed content of How to batch replace custom column values ​​in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:zmingcx.com. If there is any infringement, please contact admin@php.cn delete