Replace old domain with new domain after migration in WordPress

I have shifted my old WordPress website to a new domain, and you’re facing the fact that the image and image alt attributes have broken. I mean, it’s showing the old domain. You’re in the right place because I was also facing the same problem while migrating the website from the old domain to the new domain. Below, I have discussed all the solutions that can help you solve your problems

Table of Contents

SQL solution

If you’re familiar with SQL, then just follow these steps to solve your problems

  • First, go to the database option and open your website’s WordPress database. Below, I have shared a screenshot of my database
database
  • Now click on wp_posts, where all our posts are stored in the post_content column. Below, you can see a screenshot where wp_posts shown
wp_posts
  • Now Go to the SQL option which you can see below
  • Now Run this SQL code UPDATE wp_posts SET post_content=(REPLACE (post_content, ‘codingpoint.tech’,’codingtube.tech’)) but wait, first replace your old domain with a new domain Here, my old domain was codingpoint.tech and the new domain is codingtube.tech

Now Your broken image and image alt attributes will get fixed

Plugin solution

If you’re looking to solve your problem with a plugin, then follow the below steps

  • To solve your problem using a plugin, first, you have to download a plugin whose name is Better Search Replace
  • Now install this plugin and then go to the tools option in the WordPress dashboard, where you can just put what you want to replace, either a domain or any text
Better Search Replace

By the way, I was used SQl solution to solve my problems but you can go with plugin solution if you don’t know about SQL

Leave a Comment