Leave a Reply

2 comments

  1. The WordPress functions update_post_meta() and add_post_meta() both require serializable data;

    update_post_meta ( int $post_id, string $meta_key, mixed $meta_value, mixed $prev_value = '' )

    $meta_valueMust be serializable if non-scalar

    update_post_meta()

    It looks like this in the database because those functions serialize() the array you’re passing it.

    Therefore you if you were accessing the data outside of the get_post_meta() function you would have to unserialize() the data.

  2. I think you should save the relations as one relation per one post meta – saving the relations in the array would make DB queries very difficult.

    So, either save your relations as ie post_relations_0, post_relations_1 etc, or, even better, if you plan to do some queries, save the relations in separate table.