سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top