Question

Im using the "simple fields" plugin for wordpress and have setup a field to upload files (in this case images). Im using the following code which will allow me to show a specific image/field on the frontend:

<?php 

$selected_value = simple_fields_get_post_value(get_the_id(), array(1, 1), true); 
$theImageURL = wp_get_attachment_url($selected_value);
echo '<img src="'.$theImageURL.'">';

?>

obviously in this case it uses the specific key for that field : _simple_fields_fieldGroupID_1_fieldID_1_numInSet_0

how would i go about showing multiple images from the post connector without having to specifically identify each field.

As it stands if i was to include say 3 images into the post all would use the array(1,1) a guess id just need to create an array of all relevant images

Was it helpful?

Solution

Figured this out myself

<?php
    $field_group_values = simple_fields_fieldgroup("cs_slider");
    foreach ($field_group_values as $field_group_value) {
        $theImageURL = wp_get_attachment_url($field_group_value);
        echo '<img src="'.$theImageURL.'">'; 
    }
?>

cs_slider being the slug for the field group

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top