Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Repeating images not displaying in correct order

$
0
0

Hello!

I am using a repeating image field to display a series of thumbnails on my page. Upon first publishing the page, the images appear in the order I uploaded them, however if I re-upload an image, delete an image, or make any kind of change, the images then display in a random order on the page.

They remain in the correct order in the backend, but display on the page very willy-nilly. Re-ordering in the backend has no effect.

This is the code I am using to call the images (there is some lightbox code in there, but it does not seem to effect this issue):

$post_id = get_the_ID();
    $arr = get_post_meta(get_the_ID(), 'wpcf-swatch');
    $res = '';
    foreach($arr as $k=>$v)
    {
     
        $field = wpcf_fields_get_field_by_slug( 'swatch' );
        $params = array("alt" => "", "title" => "", "width" => "80", "height" => "80", "proportional" => "true", "url" => "true");
        $params['field_value'] = $v;
        $thumbnail = types_render_field_single($field, $params, null, '', $k);
        $params['size'] = 'full';
        $fullsize = types_render_field_single($field, $params, null, '', $k);
        $res .= '<a href="' . $fullsize . '"><img src="' . $thumbnail . '"></a>';
    }
echo $res;

Does anyone know what is happening here?


Viewing all articles
Browse latest Browse all 20145

Trending Articles