There is a "_thumbnail_id" meta key for our logos and it has each value (Id) by post id.

However, we created a new logo field ( meta key = _logo) for logo image ids. We need to move meta value from "_thumbnail_id" to "_logo" in all posts.

I have searched and tested some. But there is a problem. Most of the posts have "_thumbnail_id". but posts don't have the new meta key (_logo) by the post ids. Because it's new one.

Do I need to add new meta value first in all post? ( _logo ) And then migrate the old one (_thumbnail_id) to the new one (_logo)?

How can I move the meta value to new one?


1 Answer 1


Back up your database first, then run this query in phpMyAdmin (or if you don't have phpMyAdmin, run the query out of functions.php on an admin hook using $wpdb->query):

UPDATE wp_postmeta SET meta_key = '_logo' WHERE meta_key = '_thumbnail_id'

This will preserve all of the current IDs and just change the name of the meta key. No need to duplicate information or change them one by one.

  • Very thank you. Why I didn't think of this simple one. But it's also a very smart solution. I thought that I have to add fields to every post first and move them. I just needed to replace the name :) Thank you again. You saved my day!!!
    – pulla
    Nov 13, 2017 at 21:35

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.