The Toolset documentation says you cannot place conditional statements inside of a wpv-for-each tag and I'm wondering if you have any workarounds for this. In my particular example, I have a field "wpcf-philosophy-secondary" that may contain one or more values. For each of these values, I would like it to display a post excerpt and a link (see below). Do you have any suggestions? Right now it will not function but I cannot think of another way to get it to work without using the wpv-for-each tag. Thanks for any suggestions.
- Aaron
[wpv-for-each field="wpcf-philosophy-secondary"]
[wpv-conditional if="( $(wpcf-member-philosophy-secondary) eq 'Charlotte Mason' )"]
<h3>Charlotte Mason</h3>
[wpv-post-excerpt item="846"]
<p><a href="[wpv-post-url item="846"]">Click Here to Read More</a></p>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-member-philosophy-secondary) eq 'Classical' )"]
<h3>Classical</h3>
[wpv-post-excerpt item="861"]
<p><a href="[wpv-post-url item="861"]">Click Here to Read More</a></p>
[/wpv-conditional]
[/wpv-for-each]
Hi, there is no known workaround other than a fully custom, code-based solution. You can access an array of repeating custom field values using WordPress get_post_meta(), then loop over them using foreach. Here's an example:
https://stackoverflow.com/questions/14912739/repeatable-custom-field-display
Types custom fields use the wpcf- prefix in the database, so prepend wpcf- to the field slug shown in wp-admin. Then you would have to recreate the conditional logic in PHP and return the correct output. The WordPress codex has some examples of custom shortcodes:
https://codex.wordpress.org/Shortcode_API
I ended up doing this by creating an additional custom post type and through relationships and views cycling through it that way.