I'm looking to insert this serialized value into a meta_value
in the wp_postmeta
table
a:1:{s:8:"quantity";s:1:"2";}
I've tried numerous things
Such as creating the associative array manually.
$defaultquantityarray = array('quantity' => '2');
$defaultquantity = serialize($defaultquantityarray);
update_post_meta( $post_id, '_default_attributes', $defaultquantity);
I've also referenced the update_post_meta documentation and found reference to something like this
$escaped_json = 'a:1:{s:8:"quantity";s:1:"2";}';
update_post_meta( $post_id, '_default_attributes', wp_slash( $escaped_json ));
and additionally with a:1:
.
Both result in this insert into my meta_value
row
s:29:"a:1:{s:8:"quantity";s:1:"2";}";
This is all being performed in a WP_Query loop.
How do I insert a meta_value of a:1:{s:8:"quantity";s:1:"2";}
into my _default_attributes
meta_key?