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

I would like to display metabox repeater fields on the frontend.

Here is the code to setup the metabox repeater fields:

$my_meta =  new AT_Meta_Box($config);  

$repeater_fields[] = $my_meta->addText($prefix.'t_field_id',array('name'=> 'Title'),true);
$repeater_fields[] = $my_meta->addText($prefix.'d_field_id',array('name'=> 'Description'),true);
$repeater_fields[] = $my_meta->addText($prefix.'p_field_id',array('name'=> 'Price'),true);
$repeater_fields[] = $my_meta->addImage($prefix.'i_field_id',array('name'=> 'Image'),true);
$my_meta->addRepeaterBlock($prefix.'re_',array('inline' => true, 'name' => 'This is a Repeater Block','fields' => $repeater_fields));      

I tried to use this code:

$title = get_post_meta(get_the_ID(),'mt_t_field_id',true); 
                    echo $title;

Any advice?

share|improve this question
up vote 1 down vote accepted

Nice to see people using my class :)

Anyway when you save a field in a repeater block , to access the data you need to use the repeater ID which in your case it's

   $repeater_data = get_post_meta(get_the_ID(),$prefix.'re_',true);

and this returns an array of arrays with the id as key and value as value so you can loop over the array like this:

foreach($repeater_data as $arr){
   echo 'title: ' . $arr[$prefix.'t_field_id'];
   echo '<br />Description: ' . $arr[$prefix.'d_field_id'];
   echo '<br />Price: ' . $arr[$prefix.'p_field_id'];
   echo '<br />image: <img src="' . $arr[$prefix.'i_field_id']['url']">';

to understand better how an image field is stored take a look at the class's wiki or the comments on this post

share|improve this answer
you rocks thanks so much !! – wordpress nooby Apr 2 '12 at 12:04
just a little question, why the foreach data return an invalid argument supplied... $repeater_data is an array ? – wordpress nooby Apr 2 '12 at 15:14
I can't tell without seeing your code, but you can simply do a var_dump($repeater_data); once to see whats going on there. – Bainternet Apr 2 '12 at 15:21
ok all is fine i was make a mistake with the $prefix... so noob :) all apologies and thanks again sir – wordpress nooby Apr 2 '12 at 15:27
Glad it worked out for you – Bainternet Apr 2 '12 at 15:44

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.