admin管理员组文章数量:1391951
So I have this photography website using ACF with flexible content. It has approximately 300 posts. Due to requirements, I need to update the name of some fields.
I've tried the following query:
UPDATE wp_postmeta SET meta_key = 'content_0_left_col_image_' WHERE meta_key = 'content_0_left_column_image';
UPDATE wp_postmeta SET meta_key = '_content_0_left_col_image_' WHERE meta_key = '_content_0_left_column_image';
Rows are affected (so everything's updated) but when I go ahead and try view any of the existing posts, the data inside that field is gone.
Any ideas what could be wrong?
Thanks!
So I have this photography website using ACF with flexible content. It has approximately 300 posts. Due to requirements, I need to update the name of some fields.
I've tried the following query:
UPDATE wp_postmeta SET meta_key = 'content_0_left_col_image_' WHERE meta_key = 'content_0_left_column_image';
UPDATE wp_postmeta SET meta_key = '_content_0_left_col_image_' WHERE meta_key = '_content_0_left_column_image';
Rows are affected (so everything's updated) but when I go ahead and try view any of the existing posts, the data inside that field is gone.
Any ideas what could be wrong?
Thanks!
Share Improve this question edited May 2, 2016 at 14:52 Sumit 4,8542 gold badges28 silver badges36 bronze badges asked May 2, 2016 at 14:35 JohannJohann 8674 gold badges14 silver badges31 bronze badges 1- 1 The query you are doing is pretty much the right way to do it, except I'm guessing you didn't rename them correctly and you only need one query. What is the meta key you originally have and what is the new one you want? Also don't forget to update the declaration of the custom field once that query is run. Keep in mind that since your query has already ran, you already renamed some meta_keys, this is why they don't appear anymore. – Tofandel Commented Mar 11, 2020 at 16:34
1 Answer
Reset to default -1I hope I understand the question correctly
UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'old_value', 'new_value') WHERE `meta_key` LIKE 'your_key'
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.
UPDATE `TABLE` SET `FIELD2` = `FIELD1'
本文标签: Update field name without losing the value
版权声明:本文标题:Update field name without losing the value 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744679639a2619322.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论