block_sub_field()

Description

The block_sub_field() function will return the value of a sub-field. It outputs the value (echoes it) by default, but can be called without echoing.

block_sub_field( $name, $echo = true )

Parameters

  • $name (string) (Required) The name of the sub-field.
  • $echo (boolean) Whether to echo or not,

Usage

if ( block_rows( 'my-repeater' ) ) :
  while ( block_rows( 'my-repeater' ) ) :
    block_row( 'my-repeater' );

    block_sub_field( 'my-text-field' );

    $foo = block_sub_value( 'my-checkbox' );
    if ( $foo ) {
      // Do something.  
    }
  endwhile;
endif;