I referenced https://toolset.com/documentation/customizing-sites-using-php/displaying-repeating-fields-one-kind/ but wasn't certain if it was for the new repeating fields or the old way of doing things.
I have a repeating field group with a Textfield and a Numeric field and I want to get that field group's data for the current post.
Screenshot: hidden link (expires in 1 month)
Which PHP function do I use?
Thank you.
Hello,
The Repeating Field groups is based on post type, each instance of Field group is a single post, for example:
1) You need to get the related posts first, you can use Types new API functiontoolset_get_related_posts () to get the related posts of repeating field group:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
You will be able to get the related post IDs
2) Then use post ID to get the post meta value, render each post's custom field with Types function types_render_field():
https://toolset.com/documentation/customizing-sites-using-php/functions/
More help:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
See screenshot:
hidden link
I get the post IDs from `toolset_get_related_posts()` but what do I use within `foreach`?
`types_render_field()` takes the custom field slug but can't take a specific Post ID, correct?
So does this mean I need to use `get_post_meta()`, or does Types have such a function?
P.S.
Regarding https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
It would be nice if the arguments were ordered/numbered list instead of unordered/bullet list
Thanks for the help.
Yes, you can specific the post_id parameter in Types function "types_render_field()", for example:
types_render_field('my-field-slug', array('post_id' => '123'));
For ordered/numbered list issue, I will forward it to our editor as a request.
Just what I needed. Thank you.
I am still a bit unclear how this is documented at https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield though. Guess I'm just not following along.
Anyway, due to the bug reported at https://toolset.com/forums/topic/output-repeater-fields-in-their-drag-and-drop-order-in-wp-admin-edit-screen/#post-908851, I ended up having to extend the function's arguments so I could get to the $orderby parameter (see attached screenshot). So please do fix that.
Thanks for the help!
I saw a version update come through but the changelog was vague, and I couldn't find any changelog on your site. Was this bug fixed in this latest update?