I've one custom field named as "video" and I want to copy the custom field value to my another custom field named as "theme2035_embed."

I could do it manually, but since I have more than 2500 posts so it's gonna consume a lot of time, it would be nice if someone could tell me a SQL query to do this in a click.

Confusing? let me explain you

There are two custom fields-

  1. video
  2. theme2035_embed

The custom field "video" already has values for each posts (Which is just URL of YouTube video, and is different for each posts)

Now, my new theme uses different custom field for the same function, i.e. "theme2035_embed" what I want to do is that, copy all the individual values of "video" custom field to "theme2035_embed," for each post, counts around 2500.

And later, delete this custom field called as "video."

Update - I figured it out, in case if anyone wants to know the SQL code

update wp_postmeta 
set meta_key = 'theme2035_embed' 
where meta_key = 'video'
  • Note: You could achieve the same effect "internally" to WordPress, without directly manipulating or necessarily even altering the DB via SQL.
    – CK MacLeod
    Jul 20 '16 at 16:41
  • Sure, if there's an alternate way then please share it in the answers :)
    – Pranjal
    Jul 21 '16 at 17:14

Here's the solution

update wp_postmeta  set meta_key = 'theme2035_embed'  where meta_key = 'video'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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