Home > Enterprise >  replace a word in all wordpress posts and pages, title,excerpt and content
replace a word in all wordpress posts and pages, title,excerpt and content

Time:10-19

I am new to mysql and phpmyadmin so excuse my question if it's basic. I need a query to replace the 15$ to 10$ on all posts and pages post_title, post_excerpt and post_content using the insert method not update method. also is there any way to undo the query if things went wrong ?

CodePudding user response:

You should back up your database first from PHPMyAdmin -> Export.

You can't replace without UPDATE.

As a second solution, after backup, if your MySQL dump is small enough, you could edit the SQL file with Notepad , replace 15$ with 10$ and import everything in a new database and switch DB connections.

CodePudding user response:

I'm not sure what your database looks like without an example and I'm not sure why you want to avoid the update method but maybe this will help you with your question.

This does use the update function however but I don't see a way around it other than exporting your database to an sql file, updating the rows through either a script or search and replace in a text editor.

My solution would be to use your text editor or use a query like UPDATE posts SET post_title = REPLACE(post_title,'$15','$10');

You might also want to take a look at this: How to search and replace all instances of a string within a database?

  • Related