> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/functions/get_acpt_block.md).

# get\_acpt\_block

Fetch block values from a Flexible Content field

Fetch every block matching a given block name, nested inside a Flexible Content field. If the same block type repeats multiple times in the field, every occurrence is returned.

### Usage

```php
$blocks = get_acpt_block([
    'post_id'           => 123,
    'box_name'          => 'box',
    'parent_field_name' => 'flexible_field',
    'block_name'        => 'text_image',
]);

foreach ($blocks as $block) {
    // each $block is one occurrence of "text_image"
}
```

### Parameters

| Parameter              | Type    | Required                 | Description                                                                                        |
| ---------------------- | ------- | ------------------------ | -------------------------------------------------------------------------------------------------- |
| `post_id`              | integer | Conditional              | The post ID                                                                                        |
| `term_id`              | integer | Conditional              | The term ID                                                                                        |
| `user_id`              | integer | Conditional              | The user ID                                                                                        |
| `comment_id`           | integer | Not currently functional | Accepted, but see warning below                                                                    |
| `wc_product_attribute` | integer | Conditional              | The WooCommerce product attribute ID                                                               |
| `option_page`          | string  | Conditional              | The option page slug                                                                               |
| `box_name`             | string  | Required                 | The meta box name                                                                                  |
| `parent_field_name`    | string  | Required                 | The parent Flexible Content field name. Also accepted as `parentFieldName`                         |
| `block_name`           | string  | Required                 | The block name. Use dot notation (e.g. `outer.inner`) to reach a block nested inside another block |
| `with_context`         | boolean | Optional                 | Wrap each returned field value in a `{before, value, after}` object                                |
| `format`               | string  | Optional                 | `only_value` (default) or `complete`                                                               |
| `return`               | string  | Optional                 | `object` (default) or `raw`                                                                        |

Exactly one of `post_id`, `term_id`, `user_id`, `option_page`, or `wc_product_attribute` must be provided to identify the location.

{% hint style="warning" %}
`comment_id` is accepted without a validation error, but is currently **not** wired to any location resolution in this function — passing only `comment_id` returns `null`.
{% endhint %}

### Return

| Type    | Description                                                                                       |
| ------- | ------------------------------------------------------------------------------------------------- |
| `array` | An array of blocks matching `block_name` — each entry is that block's own field name → value data |
| `null`  | If the parent Flexible Content field does not exist or has no blocks                              |
