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

Etch

Learn how to use Etch with ACPT dynamic data

ACPT offers a native integration with Etch. All your ACPT fields are automatically available as dynamic data inside any Etch template — no additional setup or file patching is required.

The integration hooks into Etch's etch/dynamic_data/* filters and injects all ACPT field values under the acpt key of the relevant data object.


General usage

For the full Etch dynamic-data syntax, refer to the Etch custom fields documentation.

ACPT fields follow the same convention, namespaced under acpt:

Context
Syntax

Post / Page

{meta.acpt.boxName_fieldName}

Taxonomy

{category.acpt.boxName_fieldName}

User

{user.acpt.boxName_fieldName}

Option page

{options.acpt.{option_page_slug}_boxName_fieldName}


Field value structure

Every ACPT field value is wrapped in a context object with three keys:

{
  before: string | null,
  value:  <the field value>,
  after:  string | null
}

To read just the value, chain .value:

before and after contain any prefix/suffix configured in the field's advanced options.


Text-based fields

The following field types return a plain string in .value:

  • Text / Textarea / Password

  • Editor (returns HTML with paragraph tags)

  • HTML

  • Email

  • Color (returns a hex string, e.g. #ff5733)

  • Embed (returns the raw embed URL or HTML)

  • Icon (returns the icon identifier string)

  • Toggle (returns "1" when on, "0" or empty when off)


URL field

The URL field returns an object with both the raw URL and an optional label:

Usage:


Number, Rating, and Range fields

These fields return a numeric value in .value:


Currency field

Returns an object with the amount and the currency unit:

Usage:


Length field

Returns an object with the measurement value and its unit:

Usage:


Weight field

Returns an object with the weight value and its unit:

Usage:


Phone field

Returns an object with the dial prefix and the raw number:

Usage:


Date field

Returns an object with the formatted date string and the format used:

Usage:


Datetime field

Returns the same structure as the Date field, but the value includes both date and time:


Time field

Returns the formatted time string:

Usage:


Date Range field

Returns an object with the from and to dates as an array:

Usage:


Address field

Stores the full address text along with four additional properties automatically extracted by ACPT:

Usage:

An Address Multiple variant is also available. Its .value will be an array of the above objects — iterate it with a {#loop}.


Country field

Returns an object with the raw ISO code and a human-readable label:

Usage:


Select and Radio fields

Single-choice fields return the selected option value as a plain string in .value:


Select Multi and Checkbox fields

Multi-choice fields return an array of selected option values. Iterate with a loop:


List field

Returns an array of string items. Iterate with a loop:


Toggle field

Returns "1" when enabled, empty / "0" when disabled:


Repeater field

Returns an array of rows. Each row is an object whose keys are the sub-field names.

Nested sub-fields follow the same structure as top-level fields. For example, if a repeater row contains an image sub-field:


Media fields

Media fields return a plain object with the following properties:

Property
Type
Description

id

int

Attachment post ID

src

string

File URL

title

string

Attachment title

alt

string

Alternative text

caption

string

Caption

description

string

Description

href

string

Permalink

type

string

MIME type (e.g. image/jpeg)

thumbnailId

int | null

ID of the thumbnail attachment

thumbnail

object | null

Thumbnail as a nested attachment object

metadata

array

WordPress attachment metadata

sizes

array

Available image sizes

path

string | null

Full server path to the file

pathinfo

array

PHP pathinfo() result

Image, Audio, and Video fields

The attachment object sits directly in .value:

.value is an array of attachment objects — iterate it with a loop:

File field

The File field has a different structure. The attachment is nested under a file key, alongside an optional label:

Usage:


Barcode field

Returns an object with the source text and the generated barcode data:

Usage:


QR Code field

Returns an object with the source URL and the generated QR code image:

Usage:


Relational fields (Post, Term, User)

Relational fields return the corresponding WordPress object serialized as a plain object. All standard WordPress properties are available.

Post field (single):

Post field (many — returns an array, use a loop):

Term field (single):

User field (single):

Multi variants (Post Object Multi, Term Object Multi, User Multi) return an array of the above objects. Use a {#loop} to iterate.


Option pages

Fields registered on an option page are available under the options context. Replace {option_page_slug} with the menu slug of your option page:

All the same field-type rules apply — a text field returns a string, a gallery returns an array of attachment objects, and so on.


Shortcodes and third-party plugin output

An Editor (or Text) field can store a raw WordPress shortcode — for example a TablePress [table id="1"] or a form-plugin shortcode such as [fluentform id="3"]. You do not need a separate Gutenberg Shortcode block to render it: Etch's own Text and Raw HTML elements process WordPress shortcodes automatically, after resolving the dynamic data.

HTML-producing shortcodes (e.g. TablePress)

Pass the field's value straight into Etch's Raw HTML element:

If section_body is an Editor field whose saved content is the [table id="1"] shortcode, Etch expands it and renders the resulting table markup in place.

Text/form shortcodes (e.g. Fluent Forms, [acpt_form])

Bind the field directly. Because ACPT wraps an Editor field's value in a paragraph tag, strip it with Etch's built-in stripTags modifier so the shortcode isn't split across a <p>:

Shortcode processing here is a feature of Etch itself, not ACPT: both the Text and Raw HTML elements call WordPress's do_shortcode() on the resolved dynamic content before output. ACPT only needs to supply the raw, unprocessed field value.

Last updated