0

How to save metavalue in the following format:

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

1 Answer 1

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 and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.