Skip Navigation

[Resolved] PHP Error

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.

Our next available supporter will start replying to tickets in about 6.52 hours from now. Thank you for your understanding.


This topic contains 3 replies, has 2 voices.

Last updated by andrewD-10 12 months ago.


Hi toolset,

I have this custom code inside the toolset "settings" under the custom code tab.

* New custom code snippet (replace this with snippet description).

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.
function format_my_number($atts)
$atts = shortcode_atts(
array('num' => '','sym' => '' ,), $atts );
$num = $atts['num'];
if(number_format($num, 0, '.', ',')==NULL)
return number_format($num, 0, '.', ',');
return $atts['sym'].number_format($num, 0, '.', ',');

add_shortcode('format-currency', 'format_my_number');

Unfortunately, I am getting an error

[10-Sep-2020 10:22:56 UTC] PHP Warning: number_format() expects parameter 1 to be float, string given in /home/w2nnms2ait2i/public_html/wp-content/toolset-customizations/currency_format.php on line 14

I am a little confused on how to fix this but I believe it has something to do with how the label is made. This code allows one of my number columns in a toolset field to be displayed in a currency format.


Line 14 is: if(number_format($num, 0, '.', ',')==NULL)



Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The attribute passed to a shortcode is a string.

The PHP function number_format expects the first parameter to be a floating point number, but you are passing a string, hence you see the warning.

hidden link

You can "type cast" the string as a floating point number before using it in the number_format function like so:

$num = (float)$atts['num'];

Thank you Nigel, worked perfectly