Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » Ordering multiple image field type

  • Hi guys,

    I got multiple photos for my products.
    So I have 6 image fields.
    The first one is supposed to be the main and the 5 next are secondary.
    Each time I update my custom post type, the fields get mixed in the front end and I can’t get the right first image.

    I’m using :

    $photo = $data['wpcf-photo'];
    for($i=1;$i<=count($photo)-1;$i++) {
    echo '<a class="fancybox" rel="group" href="'.$photo[$i].'"><img src="'.$photo[$i].'" alt="" style="width:140px;height:auto;margin:0 4px;" width="140" /></a>';

    Have you the same issue?
    How can I fixe this?


Viewing 6 replies - 1 through 6 (of 6 total)
  • Dear LIJE,

    Please try following code and let me know your feedback.

    global $wp_query;
    $post = $wp_query->post;
    $photos = get_post_meta($post->ID, 'wpcf-photo');
    foreach($photos as $photo){
    echo '<a rel="group" href="'.$photo.'"><img src="'.$photo.'" alt="" style="width:140px;height:auto;margin:0 4px;" width="140" /></a>';

    The full function I used was :

    $args = array( 'post_type' => 'moto', 'posts_per_page' => 100 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    if(get_post_meta(get_the_ID(), 'wpcf-statut', true) == 'disponible' || get_post_meta(get_the_ID(), 'wpcf-statut', true) == 'reservee') {
    $modele = get_the_title();
    $data = get_post_meta(get_the_ID());
    $photo = $data['wpcf-photo'];
    echo '<tr><td style="width:302px"><a href="'.get_permalink().'"><img src="'.$photo[0].'" alt="'.$modele.'" width="300" style="width:300px;height:auto;" /></a></td>';

    It’s almost the same function.

    Each time I save, the photo get mixed. Weird.

    Well, it works but I have to save my custom post type twice. Any idea why?
    Did you reproduce this issue?

    Hi, i have the same problem anyone have the solution?

    Hi, are fields appearing in reverse order or shuffled?

    Can you try using API call?:
    types_field_get_meta_value_repetitive(‘photo’, get_the_ID());
    It should return array of values as ordered on post edit screen.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Ordering multiple image field type’ is closed to new replies.