I got some options that I expand using a repeater type field. The values I save for each field is already an array so in essence I'm saving a multi dimentional array per option. (See this weekly trading hours picker http://foxinni.com/screens/trading_hours-20120828-162304.png)

My question is this: Is it better to store the meta values in one meta field as a double serialized value, or is it better to split them into one dimentional values but storing as multiple custom fields with the same name in the db?

Reason I ask is becuase it's easier to manage just one custom field, and as I've come to find, having duplicate meta field ID's as a bit of a pain to manage. Checking the old value to verify the correct field is cumbersome imo..

1 Answer 1


I figured I'll leave the meta values saving on multiple fields in the db, because I've been doing allot of pre_get_post query filtering. Some of the features in there are for searching/filtering on post meta data and would it start making things very difficult if I was to start saving values into doubly serialized values. A good habit to keep if I was to save just single, more simple, values in the near future.

To clear up some of the issues I had... I opted NOT to use update_post_meta() when saving and just go with deleting all the values first and then adding them straight after. Checking the old value with then new one and then acting on it was getting too complex. Probably not the best practice.

if(isset($_POST[$field['id']])) {
    $new = $_POST[$field['id']];

//Store repeater fields as one dimentional array with same key meta fields
if(is_array($new) && isset($new[0])){

    delete_post_meta($post_id, $field['id']);   

    foreach ($new as $key => $value) {
        add_post_meta($post_id, $field['id'], $value);  


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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