Support

Account

Home Forums Add-ons Repeater Field Using get_post_meta as Fallback on Repeaters Reply To: Using get_post_meta as Fallback on Repeaters

  • that is good. you see that it works 😉
    the 8 is because you echo $row_count--;
    and testimonials_7_testimonial is the field name for the last row.

    now use something like that:

    $rows = get_post_meta( 348, 'testimonials', false ); // get number of rows, is inside a array
    $row_count = $rows[0]; //get row number out of array
    $row_count--; // because first row start with 0 not 1 subtract one from row number
    $lastrow_content =  'testimonials_'.$row_count.'_testimonial'; //get last row field
    $lastrow_head = 'testimonials_'.$row_count.'_testimonial_header'; //get last row field
    $end_testimonial_content = get_post_meta( 348, $lastrow_content, true );// get the last row value
    $end_testimonial_header = get_post_meta( 348, $lastrow_head, true ); // get the last row value 
    $last =  '<blockquote>' . $end_testimonial_content . '</blockquote><p>' . $end_testimonial_header . '</p>';
    echo $last;