Update WordPress links with SQL

It’s not easy changing your WordPress site links. You might have to change http to https or correct a spelling error. If changing settings or using plugins don’t help, here’s how to change it manually with SQL.

Most of us will have to use phpmyadmin. Find your database manager.  In your database command line execute the query:

UPDATE wp_posts SET post_content= REPLACE (post_content, “an old link”, “a new link”)

replace “an old link” with the link you want to replace
set “a new link” the link you want to replace it too
wp_posts is our data table
post_content is the column name containing the link

Double check your query.

Now execute!

If you want to search part of a string, let’s say the ‘Word’ in ‘WordPress’, you would use ‘Word%’. The ‘Word%’ will find any instance of a string that starts with ‘Word’.

You might have to hunt down specific links on different tables. But, if you get the general principle of tables, the replace string method can go a long way.

Leave a Comment