Title: Change custom field value for all posts using phpmyadmin
Last modified: August 19, 2016

---

# Change custom field value for all posts using phpmyadmin

 *  Resolved [noonoo](https://wordpress.org/support/users/noonoo/)
 * (@noonoo)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/change-custom-field-value-for-all-posts-using-phpmyadmin/)
 * Hi, each post in my wordpress site has its own thumbnail, to display the thumbnail
   i use the custom field putting the thumbnail url in the value box.
 * To keep organised i want to move the thumbnails from the wp-content/uploads folder
   to a new folder wp-content/thumbnails but i would need to update all my existing
   posts custom field value to also point to the new location.
 * Im looking for a query i can run in phpmyadmin to find the text ‘uploads’ and
   replace it with ‘thumbnails’ in the wp_postmeta table.
 * This would change existing custom values from ‘mysite.com/wp-content/uploads/
   postpic.jpg’ to ‘mysite.com/wp-content/thumbnails/postpic.jpg’
 * I used a similar query once in phpadmin for one of my forums which replaced old
   smiley code with new smiley code for all the posts so i know its possible but
   im not sure what query i would use for wordpress.
 * Many thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/change-custom-field-value-for-all-posts-using-phpmyadmin/#post-1040178)
 * hi
 * BACK UP YOUR DATABASE using phpmyadmin before you run this query
 * `UPDATE wp_postmeta SET meta_value = replace(meta_value, 'uploads', 'thumbnails')
   WHERE meta_key = "thumbnail";`
 * above code is example showing the meta_key name as ‘thumbnail’ – change to your
   specific meta_key name. It changes the substring uploads to the substring thumbnails
   in all posts with that meta_key
 * query assumes the custom field used has the same key name in all posts, just 
   the value will change. Query limits the replace to rows with that keyname, to
   prevent unintentionally affecting other keys that were never intended to be changed.
 *  Thread Starter [noonoo](https://wordpress.org/support/users/noonoo/)
 * (@noonoo)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/change-custom-field-value-for-all-posts-using-phpmyadmin/#post-1040245)
 * Thanks for the quick reply this worked perfectly and saved so much time compared
   to editing each post manually.
 * Many thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Change custom field value for all posts using phpmyadmin’ is closed to
new replies.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [phpmyadmin](https://wordpress.org/support/topic-tag/phpmyadmin/)
 * [wp_postmeta](https://wordpress.org/support/topic-tag/wp_postmeta/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [noonoo](https://wordpress.org/support/users/noonoo/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/change-custom-field-value-for-all-posts-using-phpmyadmin/#post-1040245)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
