acf_get_block_fields()
Returns an array of all fields for the given block.
No Hooks.
Returns
Array.
Usage
acf_get_block_fields( $block );
- $block(array) (required)
- The block props.
Changelog
| Since 5.8.0 | Introduced. |
acf_get_block_fields() acf get block fields code ACF 6.8.8
function acf_get_block_fields( $block ) {
$fields = array();
// We need at least a block name to check.
if ( empty( $block['name'] ) ) {
return $fields;
}
// Get field groups for this block.
$field_groups = acf_get_field_groups(
array(
'block' => $block['name'],
)
);
// Loop over results and append fields.
if ( $field_groups ) {
foreach ( $field_groups as $field_group ) {
$fields = array_merge( $fields, acf_get_fields( $field_group ) );
}
}
return $fields;
}