-1

does exists some MYSQL query for FIND and REPLACE wp_posts AND IGNORE all other wordpress and buddypress posts (buddypress-docs) and also custom post type = portfolio ? I want to find and replace only wordpress blog content and I don't want to touch other posts. I use following MYSQL query:

UPDATE wp_posts SET post_content = REPLACE (post_content,'Item to replace here','Replacement text here');    

1 Answer 1

0

Add a WHERE clause to your query for post_type = 'post'.

5
  • UPDATE wp_posts WHERE post_type = 'portfolio' SET post_content = REPLACE (post_content,'Item to replace here','Replacement text here'); Do you mean like this? Does it ignore post_type Portfolio? May 30, 2013 at 19:07
  • 1
    that's not valid SQL, WHERE clause goes last. See the MySQL manual for how to correctly format a query. post_type = 'portfolio' will affect only portfolio type, I meant exactly as I typed it- post_type = 'post'. Look at the table itself and it will be obvious.
    – Milo
    May 30, 2013 at 19:13
  • I have only one custom post type portfolio, I am not an MySQL expert, it is a strange answer to go and look at MySQL manual how to correctly format a query, I thought that for this purpose serves this site, to do not go to any site to study MySQL language. May 30, 2013 at 19:39
  • UPDATE wp_posts SET post_content = REPLACE WHERE post_type = 'post' (post_content,'Item to replace here','Replacement text here'); Sorry, I understand now, the WHERE tells what exactly will be replaced and not what will be ignored, I am new here so I can't confirm that your answer is correct May 30, 2013 at 20:01
  • I answered as a courtesy, MySQL questions are off-topic here.
    – Milo
    May 30, 2013 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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