Skip Navigation

[Gelöst] Output format for a custom field (number)

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 4 Jahren, 1 Monat. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von martinB-16 vor 4 Jahren, 1 Monat.

Assistiert von: Minesh.

Author
Artikel
#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

Sprachen: Englisch (English )

Zeitzone: 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!