Saltar navegación

[Resuelto] A default value of zero in numerical custom fields is not an integer

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.

Este tema contiene 0 respuestas, tiene 1 mensaje.

Última actualización por Gavin 1 months, 3 weeks ago.

Autor
Mensajes
#2817446
The Custom Fields in the back-end.png
Example Custom Field.png
php error log.png

Hi Team

I wonder if you could test this out as it seems to be a consistent bug I am encountering.

I have a post type with custom numerical custom fields that are set to ZERO - 0 - as their default (see custom field image).

The custom post type is being created in PHP. I do not set the custom fields to zero because they are already set to zero as their 'default'.

When I run PHP code using the custom fields I am getting a PHP error because it thinks the numerical value is a string and not an integer (see PHP error image).

However. if I 'update' the post in the admin panel, then the numerical custom fields now indeed contain an integer with a value of zero and the PHP code works.

Thanks.

#2817459

Okay - so default values are only present when the post is 'SAVED' and not when the post is 'CREATED'.