我正在write posts面板中注册多个元数据库。在函数中。php:
$meta_boxes[] = array(
\'id\' => \'products\',
\'title\' => \'Products\',
\'pages\' => array(\'post\', \'page\', \'link\'), // multiple post types, accept custom post types
\'context\' => \'normal\', // normal, advanced, side (optional)
\'priority\' => \'high\', // high, low (optional)
\'fields\' => array(
array(
\'name\' => \'something\',
\'id\' => $prefix . \'something\',
\'desc\' => \'some description\',
\'type\' => \'checkbox\'
),
//continue with other fields
)
);
//another metabox
$meta_boxes[] = array(
\'id\' => \'customers\',
\'title\' => \'Customers\',
//etc...
我可以使用以下方法获取帖子中所有字段的值:
$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key => $value ) {
$valuet = trim($value);
if ( \'_\' == $valuet{0} )
continue;
echo $value . ":<br />";
echo get_post_meta($post->ID, $value, true) . "<br/><br/>";
}
如何获取指定的元框中所有字段的名称和值。例如,获取metabox id“products”中字段的所有值。