Skip Navigation

[Resolved] Output format for a custom field (number)

This thread is resolved. Here is a description of the problem and solution.

Problem:
Output format for a custom field (number)

Solution:
You will require to write the custom shortcode that should return the formatted number as per your requirement.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/output-format-for-a-custom-field-number/#post-1796473

Relevant Documentation:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by martinB-16 4 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1796123
Format.jpg

How can I format a custom field (number) in a page?
Example: Value 12345.6, Output € 12,345.60

Is there a syntax for the "Format" option (see picture)?

#1796473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You will require to write the custom shortcode that should return the formatted number as per your requirement.

For example:
- You can add the following shortcode to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

function display_number_in_format( $atts ) {

  $atts = shortcode_atts( array(
    'field' => ''
  ), $atts );
    $value = number_format($field, 2, ',', '.');
    return $value;
}
 add_shortcode('show-formatted-number', 'display_number_in_format');

And you can use the above shortcode by adding the shortcode block or "Fields and Text" block as:

[show-formatted-number field="[types field='preis' format='FIELD_VALUE'][/types]"]

Where:
- Please change the "preis" field value if required and adjust with your original field value.

More info:
=> https://toolset.com/documentation/adding-custom-code/

#1799523

My issue is resolved now. Thank you!