Hi,
We created a custom numeric field "some_field" attached to a custom post and allowed it to have multiple instances.
I can't find any API reference for how to fetch the instances of the field values in the correct order. I see in the database, the sort order is stored in a meta_key for the post: _wpcf-some_field-sort-order
so should we be querying the database directly, or does Toolset have a function we can call to fetch all the instances for a post_id in the correct order?
thanks
Hi,
Thank you for contacting us and I'd be happy to assist.
Whether you'll use the Toolset Types API shortcode/function ( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#numeric ) or the "wpv-for-each" shortcode ( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each ) to get the multiple instances of a custom field, the results will be in the same order as the one shown on the post edit screen.
If you'd like those results to be in some different order, then yes, you'll need custom code to first fetch those values and then return them ordered by the desired criteria.
regards,
Waqar
Hi,
Thanks for your reply.
It sounds like there is no types API function to just fetch the data, since the function and shortcode you mention are for fetching and also displaying.
Since we're using this field data in our custom code, we'll just query the database directly to get the order and then the meta values.
thanks,
Zubin
My issue is resolved now. Thank you!