[Resolved] To display repeating field still need wpv-for-each?
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to use wpv-for-each to iterate over repeating fields of a parent post?
Adding the id="$parent-slug" attribute to wpv-for-each doesn't work.
Solution:
It is not possible to set the parent directly on the wpv-for-each shortcode.
You can make this work by creating an unassigned Content Template which uses wpv-for-each and which doesn't include any id attributes, so that the shortcodes use the "current" post for their context.
But you then insert that Content Template into your template for the child posts and this is where you add the id attribute, so that for that nested Content Template its context is the parent post.
This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.
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.
Today I am trying to display repeating parent image type field with a lightbox plugin, it seems which [wpv-for-each][/wpv-for-each] is unnecessary. if I add the shortcode, the images are not shown up in fron-end, as long as I got ride of the shortcode, the images were shown. So I just wonder if this shortcode will not be necessary now? but another question appeared, can I display repeating parent image type field with lightbox plugin? because it is not working now. Thank you
Hi Nigel, it was done, but in each lightbox plugin, parent field cannot be displayed in lightbox, that means I can not use $id=‘parent-field’ into repeating field shortcode. maybe it is a small bug.
So it is not possible to set the parent directly on the wpv-for-each shortcode.
I haven't tested it but I think you could get it to work by creating an unassigned Content Template which has the markup for the slider and which doesn't include any id attributes, so that the shortcodes use the "current" post for their context.
But you then insert that Content Template into your template for the child posts and this is where you add the id attribute, so that for that nested Content Template its context is the parent post.