0

How to save metavalue in the following format:

array(
   array(
    'title' => 'something',
    'price' => 'something',
   ),
   array(
    'title' => 'something',
    'price' => 'something',
   ),
)
3

If you don't need to query on the data, you can pass arrays directly to the post meta functions, WordPress will automatically serialize/unserialize the data for you.

$your_array = array(
   array(
    'title' => 'something',
    'price' => 'something',
   ),
   array(
    'title' => 'something',
    'price' => 'something',
   ),
);

update_post_meta( $post_id, 'your_key', $your_array );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.