Skip Navigation

[Resolved] Formatted output of multiple field values

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer asked what is the correct format to load the content template shortcode, that gets the item attribute values from a repeating custom field.

Solution:
Guided that for the repeating field, it is best to wrap each instance of the content template shortcode inside the 'wpv-for-each' shortcode.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body

This support ticket is created 2 years, 10 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by a.R 2 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2289453

a.R

Why doesn´t this work?

[wpv-post-body view_template="yarpp-vorschau" item="[types field='acrh-related' format='FIELD_VALUE' separator='"][wpv-post-body view_template="yarpp-vorschau" item="'][/types]"]

THANK YOU 🙂

#2289593

Hi,

Thank you for contacting us and I'd be happy to assist.

The shortcode format that you've shared is not correct.

Assuming that the custom field with the slug 'yarpp-vorschau' includes the ID of the target post that you'd like to show using the content template 'yarpp-vorschau', the correct shortcode usage would be:


[wpv-post-body view_template="yarpp-vorschau" item="[types field='yarpp-vorschau'][/types]"]

Related links:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body
https://toolset.com/documentation/customizing-sites-using-php/functions/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2290065

a.R

Yes, that´s clear.
But how do that with MULTIPLE values?

I try to get

[wpv-post-body view_template="yarpp-vorschau" item="[types field='yarpp-vorschau'][/types] "]
[wpv-post-body view_template="yarpp-vorschau" item="
[types field='yarpp-vorschau'][/types]"]

by using

"]
[wpv-post-body view_template="yarpp-vorschau" item="

that should be between the values as separator.

Why doesn´t this work?

#2290287

a.R

Ok I guess the problem is that shortcuts are only rendered once?
So is there NO CHANCE to do that??
But it MUST be possible to handle multiple values?

#2291929

Thanks for writing back.

In the case of a repeating field with multiple values, you can cycle through each instance, using the 'wpv-for-each' shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each

For example:


[wpv-for-each field="wpcf-yarpp-vorschau"]
[wpv-post-body view_template="yarpp-vorschau" item="[types field="yarpp-vorschau"][/types]"]
[/wpv-for-each]

#2292797

a.R

Great, THANK YOU! 🙂