Home Forums ACF PRO Get title of next row in slick slider Reply To: Get title of next row in slick slider

  • there isn’t a direct way to get the next item inside of a repeater have_rows() loop, but it can be done inderectly, but this will only work for simple fields.

    while (have_rows('home-slider')) {
      // maybe get a text field from the next row
      $index = get_row_index();
      $next_title = get_post_meta($post->ID, 'home-slider_'.$index.'hero-title', true);

    If I needed a way to look ahead into repeaters, or backwards for that matter I would skip the have_rows() loop and just get the repeater as an array so that I can look at whatever I need to.

    // returns an array, each element is a row of the repeater
    $slides = get_field('home-slider');
    if (!empty($slides)) {
      foreach ($slides as $index => $slide) {
        $title = $slider['hero-title'];
        $next_title = '';
        if (isset(slides[$index+1])) }
          $next_title = $slides[$index+1]['hero-title'];