Debugging calculations in GravityMath
When a [gravitymath] shortcode prints nothing, or a number you don’t expect, turn on debugging. GravityMath then puts a numbered link after each result and adds a report after the page’s content. The report shows each formula before and after GravityMath filled in its merge tags, with the errors and warnings for that shortcode. Only administrators and editors see the links and the report. Visitors see the page as usual.
Debug one shortcode
Add debug="true" to the shortcode:
[gravitymath scope="form" id="27" debug="true"] {Hours:3:sum} * 80 [/gravitymath]In a View, open the settings of the Custom Content field that holds the shortcode and add the attribute there:
![The Custom Content field settings in the View editor, with debug="true" added to a [gravitymath] shortcode](https://www.gravitykit.com/wp-content/uploads/2026/04/gravitymath-debug-custom-content-field.png)
Debug every shortcode on a page
Add ?gv_math_debug=true to the page’s address. Nothing in the shortcodes changes, so this suits a View with calculations in several fields:
https://example.com/my-page/?gv_math_debug=trueIf the address already has a ?, add &gv_math_debug=true at the end instead.
Debug every shortcode on the site
In wp-config.php, change define( 'WP_DEBUG', false ); to define( 'WP_DEBUG', true );. Then add this line above /* That's all, stop editing! Happy publishing. */:
define( 'GV_MATH_DEBUG', true );The report shows only while WP_DEBUG_DISPLAY is on, which is the WordPress default. WordPress then also prints PHP errors on your pages for every visitor, so use this on a staging site.
Turn debugging on or off with code
The gravityview/math/debug filter decides whether debugging is on. This turns it on for every shortcode, and only administrators and editors see the report:
// Turn on debugging for every [gravitymath] shortcode.
add_filter( 'gravityview/math/debug', '__return_true' );To turn debugging off everywhere, even for shortcodes with debug="true", use '__return_false' instead.
Read here how to add these code samples to your website: Where to put code samples.
Read the report
Each result gets a link such as [0] after it, numbered in the order the shortcodes appear on the page. The link jumps to that shortcode’s box in the report. The report starts with the line “You can only see this message because you are logged in and have permissions.” Each box lists:
- The errors and warnings for that shortcode, if there are any. Common messages explains them.
- “Formula before parsing”: the formula as written. In a View’s Custom Content field, GravityView has already put in the entry’s values.
- “Processing with attributes”: the
scopeandidGravityMath used. - “Formula after parsing”: the formula with every merge tag replaced by a number. This is what GravityMath calculates.
Click (Additional info) after a line to see its details, such as the shortcode’s attributes or the entries involved.

In this View, Tom Hughes has no hours, so his formula reads * 80 before parsing and GravityMath can’t calculate it.
Common messages
| Message | What it means |
|---|---|
| Error: Unrecognized token | The formula holds text GravityMath can’t calculate. Outside a View, a shortcode with no scope causes it, because its merge tags stay in the formula. |
| Error: Unexpected token | The formula is incomplete, such as a + with nothing after it. In a View, a field that is empty in that entry leaves a gap in the formula, such as * 80. |
| No ID provided, form scope requires an ID to process the formula. | The shortcode has scope="form" or scope="view" but no id. The message names the scope. |
| Field not valid for calculation | The form has no field with the ID in brackets, or GravityMath can’t calculate with that type of field, such as a Date field. After the message, the form ID opens the form editor. |
| A field in the calculation did not contain a value | With scope="entry" and an id, the field in brackets is empty in the entry listed, and the shortcode prints nothing. With scope="form", a filter and debug="true" on the shortcode, the same line lists the entries the filter left out, whether or not their field is empty. |
| The [gv_math] formula was empty | The shortcode has nothing between its tags and no formula attribute. |
| No View was found | The id of a scope="view" shortcode is not a View. |
Show visitors that a result may be wrong
notices="true" marks a result for everyone, without the report:
[gravitymath scope="form" id="27" notices="true"] {Hours:3:sum} [/gravitymath]A result with a warning gets * after it, and a calculation that fails shows **. The end of the page then reads “* Results may not be accurate.” or “** No Results Currently Available.” With debugging on, administrators and editors see the report instead.
To change these texts, use the filters gravityview/math/accuracy_message, gravityview/math/no_results_message and gravityview/math/admin_notice (the line above the report).