Migrating a website from one domain to another is a task many website owners face. One of the most common issues during such migrations is leftover mentions of the old domain within the site’s content. These can significantly affect SEO performance and user experience. In such cases, a bulk text replacement is required — and WordPress offers several ways to do this.
Methods for Bulk Text Replacement in WordPress
Using code in the functions.php file:
For temporary text replacements, you can use custom functions inside your theme’s functions.php file. This method doesn’t modify the database, and once the code is removed, all changes are automatically reverted. For example:
// Массовая замена текста
function replace_text($text) {
$text = str_replace('old-domain.com', 'new-domain.com', $text);
return $text;
}
add_filter('the_content', 'replace_text');

Manual Editing via phpMyAdmin
If you’re confident in your database management skills, you can use phpMyAdmin to run SQL queries for text replacement. This method is more advanced and carries higher risk, as it requires precision and a good understanding of your database structure.
Example SQL query:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-domain.com', 'new-domain.com');
By applying these methods and following the recommendations, you can efficiently update data on your WordPress site after changing the domain, minimizing potential issues and ensuring a smooth experience for your users.
