Question

What is the best way to store post meta in an array (using a custom write box, know how to do that) so that all post meta is in a single custom field?

Was it helpful?

Solution

From codex:

$meta_value (mixed) (required) The value of the custom field you will add. An array will be serialized into a string. Default: None

So <?php add_post_meta(7, 'fruit', 'banana', 'apple', 'tornado', 'bob saget')

To grab them you can also use http://codex.wordpress.org/Function_Reference/get_post_custom_values

besides just get_post_meta.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top