For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

$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.

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

Last updated