🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

Plugins and Code for Batch Find and Replace to Modify Post Content in WordPress

Modified the permalinks of some articles on the site. Is there a wayto modify all related links within the site? The answer is yes.For batch replacement in the WordPress database, we can adopt the following two methods
  1. Use a Plugin for Batch Replacement
  2. Use Database Commands for Batch Replacement

Replacement Method 1: Use the Better Search Replace Plugin

Better Search Replaceis a batch search and replace tool for databasesWordPress Plugin. The plugin is in English, but it's very simple to use. The specific steps are shown in the image below:WordPress批量查找替换修改文章内容的插件和代码
  • Enter the content you want to search for in the 'Search for' field
  • Enter the content you want to replace with in the 'Replace with' field
  • Select the tables to search and replace in 'Select tables'. The table for WordPress posts is wp_posts
  • 'Case-Insensitive?' determines whether to be case-sensitive
  • 'Replace GUIDs' refers to the website domain's GUID. It is generally not selected.
  • 'Run as dry run?' If checked, it will not write directly to the database; it will only show you how many changes would be made. If you want to make the changes, uncheck this box.
A simple example. For example, if your previous article URL structure was https://blog.naibabiji.com/archives/*.html and the new URL structure is https://blog.naibabiji.com/skill/*.html, then you only need to fill in '/archives/' in 'Search for' and '/ji-qiao/' in 'Replace with'.Official Website Download Cloud Storage Download

Replacement Method 2: Use Code to Replace in the Database

This method requires using phpMyAdmin to operate on the database. If you are not familiar with database operations, it is recommended to use the plugin from Method 1 for modifications. The implementation is the same; this one uses command-line modification, while the plugin uses a graphical interface. After opening phpMyAdmin, enter your website's database and execute the following SQL code.
UPDATE wp_posts SET post_content = REPLACE(post_content, '原内容' , '替换为的内容');
WordPress Batch Content ReplacementIt is typically used when we have changed the website URL structure, or when you have modified the URL of an important article and need to batch update links referencing that URL in other articles. However, URLs written in your website's theme template files cannot be replaced using this method; only data within the database can be replaced using the methods above. For safety, it is recommended to back up your database before performing any replacements.Using a Plugin to Backup WordPress

More Methods for Batch Processing WordPress Data

If you need to batch clear articles, featured images, media library data, etc., under a WordPress category, please refer to the tutorial article below:

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow