Problem: I would like to use conditional HTML to show or hide content depending on whether or not there are any entries in the repeating field group associated with the current post.
Solution: There's no syntax in a conditional to check for the existence of entries in a repeatable field group, but you can use a View instead:
- Create a View of this RFG and add a post relationship filter where the parent is set by the page where this View is displayed.
- Set a limit of 1 result, since that's all you need to know.
- In the Loop Editor, click "Skip Wizard" since you don't need to build a Loop.
- In the wpv-items-found tags, include Views shortcodes or Types shortcodes necessary to display content when results are found. If you want to display information from the parent post instead of the RFG, use the id="$current_page" option in the field shortcode like this:
[types field="your-field-slug" id="$current_page"][/types]
- Insert the View in the current post template.
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)
This topic contains 6 replies, has 2 voices.
Last updated by 6 years, 1 month ago.
Assisted by: Christian Cox.