Navigation überspringen

[Gelöst] Determine how many values a custom field has

This support ticket is created vor 4 years, 3 months. 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 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 1 reply, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 4 years, 3 months.

Assistiert von: Minesh.

Author
Artikel
#2288119

I'm working on an old site that displays Toolset fields using PHP code. I know how to determine if a field has a value, but how can I check to see if it has more than one (before doing anything else). RIght now I am checking with:

if ( !empty( types_render_field( 'documents', array() ) ) ) {
...
}

But I want to determine if more than one document has been added (the field is set to allow for multiple) before it gets into the display code.

Thanks!
Bob

#2288403

Minesh
Unterstützer

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

To check how many number of instances of repeating field is there, you should try to use the following code:

$docs =  types_render_field( 'documents', array());
if ( count($docs) > 1 ) {
echo "it has multiple repeating field value";
}