• Resolved noonoo

    (@noonoo)


    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)
  • 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

    (@noonoo)

    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.