Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm just wondering if this is possible because the variation names listed in the products have text which is not really necessary even though I have deleted the category, its still appearing. Hope you guys can help get out of this stuff.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I'm not sure if there's a WordPress-specific way to do this, but you can do a quick find-and-replace for the offending terms.

I don't know if it follows a pattern, but if you have access to the site through SSH you could do a MySQL dump and find/replace/reimport easily.

Try this:

mysqldump -uDBUSER -p DBNAME > mysql.dump
vim mysql.dump
:%s/SEARCHTERM/REPLACEMENT/g
:x
mysql -uDBUSER -p
DROP DATABASE DBNAME; CREATE DATABASE DBNAME; USE DBNAME; SOURCE mysql.dump;
QUIT

That will, in order:

  1. Create a backup of your database named mysql.dump
  2. Open the new database backup in Vim
  3. Do a find-and-replace for the whole database
  4. Save and close the modified file
  5. Log into MySQL
  6. Delete the current table, create a new one with the same name, select it, and load it with the modified data
  7. Exit MySQL

It would probably be wise to create a second backup that isn't modified just in case something goes wrong.

Also, make sure you swap out the placeholder values for database credentials, as well as your SEARCHTERM and REPLACEMENT values.

You could do all of the steps above with other tools as well (such as phpMyAdmin and a text editor); it's just a bit quicker if you can slam through it all in a terminal window. (This is especially useful if the database is too big to upload in one piece through phpMyAdmin.)

UPDATE:

There's an even easier way to do this that I've started using. You can actually do the find-and-replace as part of the mysqldump command:

mysqldump -uDBUSER -p DBNAME | sed -e 's/SEARCHTERM/REPLACEMENT/g' > db_dump.sql
mysql -uDBUSER -p
DROP DATABASE DBNAME; CREATE DATABASE DBNAME; USE DBNAME; SOURCE mysql.dump;
QUIT
share|improve this answer
    
Thanks. I have tried doing this. It really help me a lot. ;) –  Jivers Leuman Jan 11 '12 at 0:53
    
Glad it helped! –  jleng Jan 11 '12 at 4:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.