I’m registering multiple metaboxes in my write posts panels. In functions.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...
I’m able to get all the values of fields in a post using:
$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/>";
}
How can I get the names and values of all fields within a metabox that I specify. For example get all values of fields in metabox id “products”.
my advice is look at how this is represented in the db (probably in postmeta table) and use $wpdb – the wordpress db connection class to query the db using the post id and the meta-box name for the fields name – actually someone already did this, as an extension to meta-box – saw a reference in meta-boxes site.