Appearance
Utility Functions
Utility functions provide general-purpose helpers for data manipulation, encoding, and text processing.
default
Returns the value if it is not null or empty; otherwise returns the fallback.
Signature: default(value, fallback?)
| Parameter | Type | Default | Description |
|---|---|---|---|
value | mixed | -- | The value to check. |
fallback | mixed | "" | The fallback value if value is null or empty. |
`{ {default(row.nickname, row.name)}}`
// If nickname is empty, show name
`{ {default(row.bio, 'No bio provided')}}`
`{ {default(row.avatar, '/images/default-avatar.png')}}`count
Returns the number of elements in an array. Returns 0 for non-array values.
Signature: count(array)
`{ {count(row.items)}}` items
// 5 items
`{ {count(row.tags) > 0 ? join(row.tags, ', ') : 'No tags'}}`json_encode
Converts a value to a JSON string.
Signature: json_encode(value)
`{ {json_encode(row.settings)}}`
// {"theme":"dark","lang":"en"}Useful for passing structured data to JavaScript or storing as a string.
json_decode
Parses a JSON string into an array/object.
Signature: json_decode(string)
`{ {count(json_decode(row.tags_json))}}` tagsReturns an empty array if parsing fails.
random
Returns a random integer between min and max (inclusive).
Signature: random(min?, max?)
| Parameter | Type | Default | Description |
|---|---|---|---|
min | number | 0 | Minimum value (inclusive). |
max | number | PHP_INT_MAX | Maximum value (inclusive). |
`{ {random(1, 100)}}`
// Random number between 1 and 100
`{ {random(1, 6)}}`
// Simulates a dice rollslug
Converts a string to a URL-friendly slug using WordPress sanitize_title().
Signature: slug(value)
`{ {slug(row.title)}}`
// "Hello World! 2025" → "hello-world-2025"
`{ {slug(row.name)}}`
// "John O'Brien" → "john-obrien"truncate
Truncates a string to a maximum length, appending a suffix if truncated.
Signature: truncate(value, length?, suffix?)
| Parameter | Type | Default | Description |
|---|---|---|---|
value | string | -- | The string to truncate. |
length | number | 100 | Maximum character count. |
suffix | string | "..." | String to append when truncated. |
`{ {truncate(row.description, 150)}}`
// "A very long description that..." (150 chars + "...")
`{ {truncate(row.title, 50, ' [more]')}}`
// "The quick brown fox jumps [more]"If the string is shorter than length, it is returned unchanged (no suffix added).
remap
Restructures an object by mapping new field names to old field names.
Signature: remap(source, mappingJson)
| Parameter | Type | Description |
|---|---|---|
source | object/array | The source object to remap. |
mappingJson | string | A JSON string mapping {"newKey": "oldKey", ...}. |
{ {remap(row, '{"title": "post_title", "body": "post_content"}')}}
// { post_title: "Hello", post_content: "..." } → { title: "Hello", body: "..." }Returns an empty array if the source is not an array. Returns the source unchanged if the mapping JSON is invalid.
Use in Mapping nodes
The remap() function is most commonly used in the Mapping node to restructure rows from an API or WordPress query:
expression: remap(row, '{"name": "post_title", "date": "post_date", "author": "post_author"}')Examples
Safe division with default
`{ {default(number_format(row.total / max(row.count, 1), 2), '0.00')}}`Generate a unique key
`{ {slug(row.title) ~ '-' ~ random(1000, 9999)}}`Truncated preview with item count
`{ {truncate(row.body, 200)}}` (`{ {count(json_decode(row.attachments))}}` attachments)