So here’s the situation:
I’ve got a custom post type setup with 1 ACF field — True/False field. After adding 100+ posts to my cpt, I later changed my mind on the ACF field where I want to use the Radio Field.
So, upon switching, I need to update each cpt post with the default value.
Is there a quick way to do that via phpMyAdmin?
Thanks,
Hi @sdacreative
Yes, there is a quick way.
You will need to write some code which performs an UPDATE on all rows in the wp.post_meta table WHERE the meta_key is the field_name. You want to SET the meta_value cell to the new value (“yes” – i suppose)
Does that help?
Thanks
E
Thanks for your help, Elliot! I was able to write the SQL command:
UPDATE wp_postmeta SET meta_value = 'No' WHERE meta_key = 'block';
But the problem is, that meta_key doesn’t exist in the database until a value is saved within the custom post type. I think the reason is because I switched the field from a True/False field to a Radio Field.
Check out these screenshots:
File 1: This shows the missing value for the custom post type that I want to update via phpMyAdmin (remember, there are 100+ of these). Right above it, the value exists because I edited the cpt and re-saved it.
File 2: This shows the that field exists in the database for ‘alfr’ (as shown in File 1)
File 3: This shows that the field doesn’t exist in the database for ‘all-2’ (as shown in File 1).
Since the database has no record of it, I can’t use my UPDATE command.
Thoughts?
Hi @sdacreative
Perhaps you also need to update the meta_key?
Thanks
E