Problem: I would like to know how to loop over repeating field groups with PHP.
Solution:
Use the toolset_get_related_posts API. Each RFG can be accessed as a child, where the post is the parent and the relationship slug is the RFG slug.
$parent = get_post( 12345 ); // the parent post that holds the RFG $sezioni = toolset_get_related_posts( $parent, // the parent post 'sezioni', // the RFG slug 'parent', // the post role in this relationship is 'parent' 1000000, // the maximum number of results 0, // the offset array(), // additional query arguments 'post_id', // return format 'child', // role to return ); // $sezioni is now an array of post IDs for each RFG $sez1 = get_post( $sezioni[0] ); // example, get the first Sezioni RFG ID $pulsanti = toolset_get_related_posts( $sez1, // the parent RFG 'pulsanti', // the RFG slug 'parent', // the sezioni role in this relationship is 'parent' 1000000, // the maximum number of results 0, // the offset array(), // additional query arguments 'post_id', // return format 'child', // role to return ); // $pulsanti is now an array of post IDs for each RFG in $sez1
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 3 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 6 Jahren, 5 Monaten.
Assistiert von: Christian Cox.