Navigation überspringen

[Gelöst] Obtain Count of Repeating Fields with Condition

This support ticket is created vor 5 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.

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

Assistiert von: Minesh.

Author
Artikel
#1391017

I'm looking to return the number of instances of a repeating date field in a post where the date is on or before today. I came across this but it counts ALL instances.

$dates= sizeof(get_post_meta( $post_id, 'wpcf-custom-field', false));

I can do it using an SQL query in my function but wondered if there's a different/better way of doing it?

Thanks

#1391043

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

There is no way to get total count of repeating field instances. You need to use the PHP code as you shared.

Please check the following related ticket where I shared the shortcode that returns the total count of repeating field instance:
=> https://toolset.com/forums/topic/conditional-on-amount-of-repeatable-fields/#post-1389441

#1394389

My issue is resolved now. Thank you!