Migrating question:
How would I structure a MySQL query to move the value from one meta_key to another meta_key?
eg: I have an old meta_key of “guest_sort” associated with “posts” to “tf_exhibitor_sort” under the post type “exhibitor_listing”
I’ve already moved the posts from the original post category over to the post_type. Still possible, or am I outta luck and will have to do some data-entry?
Thanks.
I hope I understand the question correctly .
When you move a post , the meta keys and values associated with it should remain with the post itself, like all post meta (including the attachments , custom-image etc..) – so there should be no problem to keep the values.
Normally ,The only thing that SHOULD happen is a change the ‘post_type’ property of the post.
but anyhow, if your question is about RENAMING meta keys , then this should dod the trick :
Of course, to update VALUES you can use the same approach
EDIT 1 : i forgot to mention : ** BACKUP YOUR DATABASE BEFORE ANY TRIAL **
EDIT 2 : following comment :
To copy from one field to another (I got a bit confused with your naming and which value you want where , so I post the generic sentence.
defo back up your data!! it might not be the most efficient, but you could also do this w/ WP functions instead of SQL queries if you are more comfortable speaking WP (like i am)
run this one time:
you can just delete it after you reload your theme once (and add that function to an init hook or something). or you could be super cool and use this ‘run once’ code i found from Bainternet.
You can use
wp_schedule_single_event
to run once.Other way maybe:
So, friend came up with a script for this. You put it in your root folder of your instal and it flips the values from one meta key to the other. I thought I’d share it in case anyone else need it.