Problem:
Setup Repeating Fields sort order using PHP codes.
Solution:
Toolset Types plugin is using a custom field to store the sort order of Repeating Fields, the field slug is "_wpcf-{field-slug}-sort-order", and field value is in serialized array format.
For example Repeating Fields "start-date", the sort order field slug is "_wpcf-start-date-sort-order", and field value is:
a:3:{i:0;i:648;i:1;i:649;i:2;i:650;}
Above numbers 648, 649 and 650 are "meta_id" values of each instance, you can get them with add_post_meta() function of your PHP codes, see WP document:
https://developer.wordpress.org/reference/functions/add_post_meta/#return
Return #Return
(int|false) Meta ID on success, false on failure.
Then update the sort order field value with function update_post_meta().
Then update the sort order field value with function update_post_meta().
Relevant Documentation:
https://developer.wordpress.org/reference/functions/add_post_meta/#return
https://developer.wordpress.org/reference/functions/update_post_meta/
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 |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9: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/Hong_Kong (GMT+08:00)
This topic contains 7 replies, has 2 voices.
Last updated by 4 years, 7 months ago.
Assisted by: Luo Yang.