WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my functions I'm registering multiple metaboxes with custom fields. A single metabox array for instance, looks like this:

In functions.php

$meta_boxes[] = array(
    'id' => 'general_info',
    'title' => 'General Information',
    '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(
            'name' => 'Asking Price',
            'id' => $prefix . 'asking_price',
            'type' => 'text',
            'std' => ''
            'name' => 'Currency',
            'id' => $prefix . 'currency',
            'type' => 'text',
            'std' => 'USD'
            'name' => 'Salesman',
            'id' => $prefix . 'salesman',
            'type' => 'text',
            'std' => 'Your Name'

In my theme, how can get all the field names (and even values if possible) from metabox general_info ? I'm trying to retrieve data from each metabox separately.

share|improve this question
up vote 0 down vote accepted

Use get_post_custom, it will return an array of all the posts meta info. http://codex.wordpress.org/Function_Reference/get_post_custom

share|improve this answer
Thanks but I need post meta for metabox named "general_info" only. I have many metaboxes – at least three characters Dec 5 '11 at 4:09
Then use get_post_meta with the key being "general_info". – Wyck Dec 5 '11 at 4:52
that will give me the key for the meta value not all the fields in the array. I'm having trouble finding a solution for this. Maybe I'm not explaining right – at least three characters Dec 7 '11 at 21:52

you have to return metabox. place the below code at the end

return $metaboxes;

This will solve your problem

share|improve this answer
And why would this work? Please explain your suggestion. And BTW, it's $meta_boxes. – tfrommen Feb 24 '14 at 10:18
We need to return an array to retrieve data from metabox, which u saved as an array. – Bhanu Prakash Mar 1 '14 at 6:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.