Reputation: 239810
I maintain a Wordpress site for a client of mine. They do all the content, I just keep it running and do the theme work.
A site they've linked to a few hundred times has changed domain and they've (very rudely) not redirected traffic from their old domain, so users clicking on an old link see a 404.
So we're left in the position where we need to fix all the links. The static ones (in theme files) have been easy enough to replace but, as I say, there are hundreds of these blighters littered all over the website in the posts.
Is there a quick method to find-and-replace links like this?
If there's not a Wordpress or PHP method, I'm happy to log in to the database over SSH and fire some SQL off manually... But what SQL do I want?
Upvotes: 0
Views: 676
Reputation: 28541
There also is a WordPress plugin for that: http://wordpress.org/extend/plugins/search-and-replace/ I have used it when moving my own site and it worked nicely.
Upvotes: 3
Reputation: 449415
Running a query is indeed the easiest and cleanest way.
Back up the database of course
According to this blog post (I'm too lazy to look the columns up on a live WP but this looks about right), the right query is
UPDATE wp_posts SET post_content =
REPLACE (post_content,
'http://www.oldsiteurl.com',
'http://www.newsiteurl.com');
Upvotes: 3