You are here: Daniel Dumas » Blog, Tips and Tutorials, Wordpress »

WordPress Search and Replace

WordPress Search and Replace

Hey everyone, I am alive again to blog after a long time haha welcome back to me. I’ve decided to blog again to make this site alive in search engines because i been out for a very long time, and my site traffic and ranks has decreased huhu.. alright so much for the blah blah..

well today I’ll share some ways on how to Search and Replace datas or texts in WordPress. this will be useful when you are transferring a wordpress blog from one domain to another or if you’ve developed a wordpress site on your localhost and you’re gonna upload it to an online server or on your own domain, of course you need to update the paths on your posts.

for example you’ve developed a wordpress site on your local machine and you installed it on http://localhost/wordpress, when you transfer the site into a live server, you need to change that path in your database for wordpress to display your blog posts or menu links correctly, and not only that – there may be times that you hardcoded a link (eg. images,post) in your blog post. i dont know for you, but for me updating it one by one is a no no.. i mean why are you gonna do it manually, when you can do it automatically? right? right? or left? haha..

Here are some other ways or situations on when you can use the search and replace function.

1. Correcting a typographical Error – you discovered that one of the words you frequently use was mispelled, for example instead of typing a bacon, you are typing in and using the word vacon with a “V” all the time (haha..)

2. Updating a Name/Word - you want to change word1 to word2, or name1 to name2

3. Deleting Weird Characters - you are copying and pasting articles from one site or documents and you didn’t noticed that some special characters are also copied eg. Â, ♠ , ¶ ,Æ and so on..

Here are some methods that you can do to search and replace texts in wordpress database or blog posts.

1. using MySQL search and replace function within PHPMYADMIN

open your wordpress database using phpmyadmin, click the SQL tab and enter the following codes:

UPDATE wp_posts SET post_content = REPLACE (
post_content,
'OLD TEXT',
'NEW TEXT');

the code above uses the MySQL replace function to first search the OLD TEXT in the wp_posts table then post_content field, and when found replace it with the NEW TEXT.

you can search and replace datas from any tables/table fields in the database. you can also use this method on any applications that uses mysql as a database.

2. using WordPress Search and Replace Plugin

same functionality as the mysql replace function, the only difference is this plugin provides a user interface within the wordpress admin panel. you can download the plugin here. http://wordpress.org/extend/plugins/search-and-replace/

NOTE: Don’t forget to create a back up of your database first before trying any of the methods above. ok? it’s better to be sure, right? :)

Enjoy! please share.

Discussion

  1. lawmacs says:

    This is a great way to simple replace old text runing a sql function is that simple will have a look at the plugin thanks for the heads up

  2. This is great, makes the process so much more efficient!

Leave a Reply





CommentLuv badge