Support

Account

Home Forums Add-ons Repeater Field Repeater – Only return 10 rows

Unread

Repeater – Only return 10 rows

  • Only want to display the first 10 rows of my repeater, below is my code – is anyone here able to help out? Thanks.

    public function widget( $args, $instance ) {
    $title = apply_filters( ‘widget_title’, $instance[‘title’] );
    $past_projects_page = get_field(‘past_projects_page’,’option’);
    if ( !$past_projects_page )
    return;

    $past_projects_link = get_permalink($past_projects_page->ID);
    if ( have_rows(‘projects’,$past_projects_page->ID) ) {
    echo $args[‘before_widget’];
    if ( ! empty( $title ) )
    {
    echo $args[‘before_title’] . $title . $args[‘after_title’];
    }
    while ( have_rows(‘projects’,$past_projects_page->ID) ) { the_row();

    $title = get_sub_field(‘title’);
    if ( !$title )
    continue;

    $title_pieces = explode(‘,’,$title);
    $short_title = strtoupper(trim(array_shift($title_pieces)));
    $slug = sanitize_title($title);

    echo ‘‘.$short_title.’<br>’;
    }

    echo $args[‘after_widget’];
    }
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.