return array( get_post_meta(12785, 'attribute_settings', true));
or
return array( get_post_meta("12785", 'attribute_settings', true));
it returns [""] changing the key with another value, it returns the value in the database.
return array( get_post_meta(12785, 'attribute_settings', true));
or
return array( get_post_meta("12785", 'attribute_settings', true));
it returns [""] changing the key with another value, it returns the value in the database.
2
Answers
Try this below code.
You mention that if you change the key, you get the value you want. Looking at your screenshot, you’ve got duplicate keys for
attribute_settings
. How you got a duplicate key in there, I’m not sure (did you add them directly in phpMyAdmin? Usingupdate_post_meta()
will update the record if it exists)Now, I haven’t seen the case before where a duplicate
post_id:meta_key
pair exists, but I’d wager it’s returning at theNULL
value since it’s first. Delete that entry and you should be good.Documentation & Function Reference
update_post_meta()