Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have install the plugin Simple fields for WordPress, create an repeatable field for file. Upload an amount of images to an portfolio item. Now I will show these images on the page. I use currently the following code:

        $file_id = simple_fields_value('image_repeater');
        $image_info = wp_get_attachment_image_src($file_id, "full");
        $image_url = $image_info[0];

        echo "<img src='$image_url' class='imagebox' />";

This will show only the first image that I have uploaded. Now I want to show also the other images, but I don't know how. Hope somebody can help me out!

Thank you!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

For repeatable fields you can use the function simple_fields_values to get an array with all the field values. You can then loop through the array and do whatever you want with the values (in this case the images).

See more info here:

http://simple-fields.com/documentation/api/getting-values/simple_fields_values/

share|improve this answer
    
Yes I have look at your documentation and try a lot of code, but I get only one image to show.... Do you can help me out with the markup. Thank you very much! @Par –  Casper Feb 6 '13 at 20:48
    
Also I check the values with var_dump and retrieve only the image that is shown. (There are more uploaded) var_dump retrieves: src, height and width. Tried also: $file_id = simple_fields_value('image_repeater'); foreach ($file_id as $src) { $src = wp_get_attachment_image_src($file_id, "full"); $src_url = $src[0]; echo "<img src='$src_url'/>"; } But noting is shown. –  Casper Feb 6 '13 at 21:06
    
What exactly does $file_ids = simple_fields_values('image_repeater'); var_dump($file_ids); return? Also, you don't happen to have another field with the same slug on the same page/post? –  Pär Feb 6 '13 at 21:36
    
I get it work: $repeatable_field_values = simple_fields_values("image_repeater"); foreach ($repeatable_field_values as $values) { $image_info = wp_get_attachment_image_src($values, "full"); $image_url = $image_info[0]; echo '<br />'; echo '<img src="'.$image_url.'" class="imagebox" />'; } Thank you for your time. @Pär –  Casper Feb 6 '13 at 21:37
add comment

Your Answer

 
discard

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.