GCBGutenberg
Control Blocks
Buy

Structured fields

Taxonomy term fields

Reference, generated from the plugin source

Taxonomy term-meta typed fields.

Same controls config shape as PostFields\Registrar — register once against a taxonomy slug, get a panel on the term edit screen rendering those controls, values saved to wp_termmeta.

Public entry point in includes/Taxonomy/helpers.php as gcblite_register_taxonomy_fields($taxonomy, $config). Themes call it the same way they call gcblite_register_post_fields.

PHP
gcblite_register_taxonomy_fields('category', [
    'controls' => [
        ['type' => 'image', 'attributeKey' => 'cover', 'label' => 'Cover'],
        ['type' => 'color', 'attributeKey' => 'accent', 'label' => 'Accent'],
    ],
]);

Stored: one row in wp_termmeta per control:

PHP
meta_key   = attributeKey
meta_value = (serialised PHP value)

(Same shape as wp_postmeta to keep get_term_meta / update_term_meta working naturally for downstream theme code.)

REST exposure: GET /wp-json/gcblite/v1/terms/{taxonomy}/{term_id}/fields returns the resolved values (defaults filled in for missing keys). Public read — term meta isn't sensitive by default; if you put secrets in a taxonomy field, don't.

Note: WP only fires {taxonomy}_edit_form on EXISTING terms. The Add-New-Term screen uses {taxonomy}_add_form_fields. We deliberately skip add-form support for now: the React Inspector can't reliably render before the term has an id (image controls need a media library context tied to the term, conditional logic can read from other meta, etc.). Authors add a term first, then fill the fields.

Functions

gcblite_register_taxonomy_fields()

PHP
gcblite_register_taxonomy_fields($taxonomy, array $config)

gcblite_get_term_fields()

PHP
gcblite_get_term_fields($taxonomy, $term_id)

Convenience wrapper around get_term_meta that fills declared defaults for missing keys, matching the REST shape.