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

  • $row_count-1; would not work because you dont save result back to a variable.
    $row_count_last = $row_count-1; should work 😉
    (you can use same variable like previous post, or a new one like this post)

    for second last you could use different ways.
    it depends on things like: do you use last row anyway.

    $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
    $row_count--; // because we already subtract 1, this is like subtract 2 from start value
    $2lastrow_content =  'testimonials_'.$row_count.'_testimonial'; //get 2last row field
    $2lastrow_head = 'testimonials_'.$row_count.'_testimonial_header'; //get 2last row field

    above only works when variable for last row is filled before.
    (it use $row_count--;)
    below works independent of ordering, last could be before or after 2last
    (this dont use $row_count--; !)

    $row_count_2last = $row_count-2;
    $2lastrow_content =  'testimonials_'.$row_count_2last.'_testimonial'; //get 2last row field
    $2lastrow_head = 'testimonials_'.$row_count_2last.'_testimonial_header'; //get 2last row field
    $row_count_last = $row_count-1; // because first row start with 0 not 1 subtract one from row number
    $lastrow_content =  'testimonials_'.$row_count_last.'_testimonial'; //get last row field
    $lastrow_head = 'testimonials_'.$row_count_last.'_testimonial_header'; //get last row field

    or you could do it a other way 😉 (fill your own array and echo that for example)