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

save_acpt_block

Create or update a dynamic block

Create or update a dynamic block.

Performs an upsert: if a block with the given name already exists (and no id is passed), its existing settings are merged with the ones you provide — so a partial update (e.g. just changing title) doesn't wipe keywords/postTypes/controls you didn't resend.

Usage

save_acpt_block([
    'name'      => 'my_block',
    'title'     => 'My Block',
    'category'  => 'widgets',
    'icon'      => 'smiley',
    'keywords'  => ['my', 'block'],
    'postTypes' => ['post', 'page'],
    'controls'  => [
        [
            'name'  => 'heading',
            'label' => 'Heading',
            'type'  => 'Text',
        ],
    ],
]);

To update an existing block, include its id:

Parameters

Parameter
Type
Required
Description

name

string

Required

The block slug (must be unique)

id

string

Optional

Block UUID — if provided, updates the existing block instead of resolving it by name

title

string

Optional

The human-readable block title

category

string

Optional

The block inserter category slug

icon

string | array

Optional

A Dashicon slug or an SVG icon definition for the block inserter

css

string

Optional

Custom CSS scoped to this block

callback

string

Optional

PHP callback used to render the block on the front end

keywords

array

Optional

Search keywords shown in the block inserter

postTypes

array

Optional

Post type slugs this block is restricted to. Empty/omitted means all post types

controls

array

Optional

Editor controls exposed for this block — each entry: name (required), label, type (one of Checkbox, Radio, Select, SelectMulti, Toggle, Text, Textarea, Number, Range, Email, Phone), default, description, settings

Return

Type
Description

bool

true on success, false on failure

Last updated