Problem: Can I embed Toolset wpv-for-each shortcodes in my PHP templates to loop over repeating fields?
Solution: No, you should use the native WordPress function get_post_meta to get the values of your repeating field, then loop over those values and output the proper HTML strings. This is not a trivial task. Here's a simple example of looping over a repeating image field in PHP:
$string = ''; $medias = get_post_meta(12345, 'wpcf-wpcf-medias', false); foreach($medias as $img) { $string .= "<a href='" . $img . "'><img src='" . $img . "' /></a>"; } echo $string;
Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_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 |
---|---|---|---|---|---|---|
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)
Ce sujet contient 1 réponse, a 2 voix.
Dernière mise à jour par Il y a 6 années et 9 mois.
Assisté par: Christian Cox.