Home > CMS Tutorial > WordPress > Batch replace text in WordPress posts

Batch replace text in WordPress posts

藏色散人
Release: 2021-07-26 16:04:12
forward
2981 people have browsed it

Batch replace text in WordPress posts

Batch replace text in WordPress articles

If you plan to replace and modify the same text scattered in a large number of WordPress articles, manually edit the article modification work If the volume is large, you can use the following code to implement batch replacement. The WordPress operating data constant $wpdb will be used to modify the database, and there is no need to log in to the database for operation.

Add the code to the end of the current theme function template functions.php:

global $wpdb;
$wpdb->query("UPDATE wp_posts SET post_content = replace( post_content, '旧文字', '新文字' )");
Copy after login

Modify the text, if there are multiple paragraphs of text, just copy a few more pieces of code, add it to functions.php, use Then delete it.

Tip: There are risks in operating the database, please make a backup in advance!

For more WordPress technical articles, please visit the WordPress tutorial column!

The above is the detailed content of Batch replace text in WordPress posts. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template