Support Log in
All Features: Advanced Custom Fields, Rebuilt

Calculation Fields — Automatic Totals From Your Data

A calculation field is a read-only numeric field whose value is computed for you — never typed by hand. Point it at other fields with a simple {field_name} formula, or sum a numeric sub-field across every row of a repeater, and Field Forge keeps the total in sync on save and on read. It is the field you reach for whenever a number should be derived from your content instead of entered manually: an order total, an invoice subtotal, a project budget, a nutrition total, a score.

The calculation field is a Pro field type. The companion cross-post aggregation tools — the [fieldforge_total] shortcode and the fieldforge_aggregate_field() helper — are available in Field Forge Free.


Two ways to calculate

A formula over sibling fields

Reference other fields on the same post by name, in braces, and combine them with + - * / ( ):

{price} * {quantity}
({subtotal} - {discount}) * 1.2
{hours} * {rate}

Field Forge substitutes each {field} with its current value and evaluates the result. The formula is never run through eval() — a whitelisted arithmetic parser handles it, so a calculation field can never execute arbitrary code, and the posted total is never trusted (the server always recomputes).

A sum across repeater rows

Set the total source to a repeater and pick a numeric sub-field, and the calculation field sums that sub-field across every row — the classic line-item total. Add an amount sub-field to a line_items repeater, point a grand_total calculation field at line_items → amount, and the total updates as rows are added, edited, removed, or reordered.


Output formatting

Calculation fields render exactly how you want the number to read:

  • Number, currency, or percentage output
  • Configurable decimal places
  • Currency symbol with prefix or suffix placement
  • Custom thousands and decimal separators

So 1234.5 can display as $1,234.50, 1.234,50 €, or 1 234,5 % — your choice, per field.


Live preview while editing

In the editor, the total updates per keystroke as you type into the fields it references or change repeater rows — so editors see the result before they save. The on-screen preview is a convenience; the authoritative value is always computed in PHP on save and on read, so it stays correct even for content created via import, REST, or WP-CLI.


Totalling values across posts

Sometimes you need a total that spans many posts — total raised across every campaign, total revenue across every order, average rating across every review. Field Forge ships cross-post aggregation in Free:

[fieldforge_total field="donation" post_type="campaign" op="sum" format="currency" symbol="$"]
$raised = fieldforge_aggregate_field( 'donation', 'campaign', 'publish', 'sum' );

Both run a single indexed SUM/AVG/MIN/MAX/COUNT over the wp_fieldforge_values table (with a guard so repeater sub-rows are never double-counted).

For headless and reporting use, Pro also exposes the same aggregate over the REST API and GraphQL:

GET /wp-json/fieldforge/v1/aggregate?field=donation&post_type=campaign&op=sum
{ fieldForgeAggregate(fieldName: "donation", postType: "campaign") { sum avg count } }

Free vs Pro

  • Free: [fieldforge_total] shortcode + fieldforge_aggregate_field() helper for cross-post totals.
  • Pro: the calculation field type (formula + repeater-sum modes, formatting, live preview) and the REST /aggregate route + fieldForgeAggregate GraphQL query.

See all 32+ field types → · Compare plans →

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs