Mass find and replace value in repeating field using SQL
-
If you ever want to do a mass find & replace on a repeating field in Toolset, here’s how.
Let’s say you have a field called “wpcf-your-repeating-field-name”. In that field, you have a value of “Old value”. You want to replace that “Old value” with “New value”. With this SQL command, you can replace all instances of “Old value” with “New value” in your field called “wpcf-your-repeating-field-name”.
Open up your PHPMyAdmin, click on your database name (in the left side bar). Then click on “SQL” in the tabs. Enter this command, and then click “Go”
UPDATE wp_postmeta INNER JOIN wp_toolset_associations ON wp_postmeta.post_id = wp_toolset_associations.child_id LEFT JOIN wp_posts ON wp_posts.ID = wp_toolset_associations.parent_id SET wp_postmeta.meta_value = 'New value', wp_posts.post_modified = '2019-08-12 14:27:09', wp_posts.post_modified_gmt = '2019-08-12 14:27:09' WHERE wp_postmeta.meta_value = 'Old value' AND wp_postmeta.meta_key = 'wpcf-your-repeating-field-name'
This command will also update your post_modified and post_modified_gmt fields in the wp_posts table. Generally, it’s probably a good idea to update the modified dates when you do this mass-update of values. Feel free to use update values for that date.
- The topic ‘Mass find and replace value in repeating field using SQL’ is closed to new replies.