A Calculation field is a read-only number field that computes a total automatically. Editors cannot type into it — Field Forge calculates the value from other fields on the same post and displays the result whenever the post is viewed or edited. The total is also stored in the database so your developer can query or expose it through REST or GraphQL without extra computation.
Calculation fields require a PRO license. On the free plan, the field type appears in the picker with a PRO badge.
Two Ways to Calculate a Total
When you add a Calculation field to a field group, you choose a Total source in the field settings:
Formula (self) — write a simple math expression that references other top-level fields in the same field group by wrapping their names in braces. For example:{price} * {qty}multiplies a Price field by a Quantity field({base_price} + {surcharge}) * {tax_rate}uses parentheses for grouping{subtotal} - {discount}subtracts a discount from a subtotal
Allowed characters: + - * / ( ), digits, and decimal points. Any other characters make the result 0. Field Forge evaluates the formula using a secure mathematical parser — no PHP code is executed.
order_items repeater with an item_total sub-field) contributes one number, and the Calculation field returns their sum. You select the repeater name and sub-field name in the field settings — no formula to write.
Output Formatting
A Calculation field can display its result as a plain number, a currency amount, or a percentage. Configure these in the field settings:
| Setting | Options | Example |
|---|---|---|
| Output format | Number, Currency, Percentage | Currency → $1,299.00 |
| Decimal places | 0–10 | 2 → 1299.00 |
| Currency symbol | Any text | $, €, £ |
| Symbol position | Prefix or Suffix | Prefix → $99, Suffix → 99€ |
| Thousands separator | Any character | , → 1,299 |
| Decimal separator | Any character | . → 1299.00 |
Live Preview in the Editor
When you or a content manager edit a post and change a value in a sibling field, the Calculation field total updates per-keystroke in the metabox. This is a display preview only — Field Forge recalculates the authoritative total on the server when the post is saved.
Example: Invoice Line Items
Imagine a “Quote” custom post type where a manager fills in line items and needs a grand total automatically:
- Add a Repeater field named
line_itemswith sub-fields:description(Text),qty(Number),unit_price(Number),row_total(Number) - Have editors compute each row total manually in the
row_totalsub-field (or use a formula Calculation sub-field once nested calc support is added) - Add a Calculation field named
grand_total
– Repeater: line_items, Sub-field: row_total
– Output format: Currency, Symbol: $, Decimal places: 2
- Editors fill in line items; the grand total displays automatically and cannot be overridden
For a simpler formula-based example with just a price and quantity at the top level:
price(Number field) andqty(Number field) are siblings ofgrand_total(Calculation)- Total source: Formula (self), Formula:
{price} * {qty} - The metabox shows the running total as the editor types
Totalling Values Across Posts
Calculation fields work on one post at a time. To add up a field’s values across many posts — for example, summing all donation amounts across every Campaign post — use the shortcode. This is a free feature.
0Place this shortcode in any post, page, or widget. It reads all published posts of the given type and returns the aggregated result. The op parameter supports sum, avg, min, max, and count.
> Good to know: The shortcode reads directly from Field Forge’s optimized database table, so it is efficient even on sites with thousands of posts. Sub-field values inside repeaters are automatically excluded from the count to prevent double-counting.
—