Description
Adds helper functions for retrieving the total count of repeater rows, and the index of an individual repeater row.
The block_row_count()
function takes a repeater field name as the argument, and returns the row count for that repeater. (It can also return false, if you pass it an invalid repeater name.)
block_row_count( $name )
Parameters
$name
(string)
Usage
if ( block_rows( 'repeater' ) && block_row_count( 'repeater' ) > 3 ): while ( block_rows( 'repeater' ) ) : block_row( 'repeater' ); // Note: The index is zero-based, so we should add 1 to get a non-programmer count. echo '<li>This is row number ' . block_row_index() + 1 . '</li>'; endwhile; echo '</ul>'; endif;