Skip Navigation

[Resolved] How to Build a Conditional Accordion That Hides Empty Fields

This support ticket is created 4 years, 3 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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#2012777

Tell us what you are trying to do?

Build an accordion that leaves out any empty fields from the accordion structure. For example if there's Bio, Education, and Awards in an accordion, and a custom field group of Education has no information for that post, I need it to not show the "Education" accordion.

Is there any documentation that you are following?

None. I wish this was documented. I think it'd be helpful.

Is there a similar example that we can see?
These attorney bios have a conditional accordion. hidden link

What is the link to your site?
hidden link

I have not instituted the accordion yet as I've just run into issues in doing so. I am building out the archive templates with Elementor, but I think this issue would occur with any accordion.

#2013111

Hello,

How do you setup the "Education" field?

If it is a custom field, you can use the conditional block to display or not display the entire "Education" accordion
https://toolset.com/course-lesson/using-toolset-conditional-block/

If it is a repeatable field groups,you will need to create a post view, I suggest you try to create the view with classic editor, for example
1) Dashboard-> Toolset-> Settings-> General:
in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build"

2) Dashboard-> Toolset-> Views, create a post view:
- Query "Education" items
- Filter by the "Repeatable field groups" relationship
- In section "Loop Editor", within shortcode [wpv-items-found] ... [/wpv-items-found], display the "Education" accordion HTML codes + "Education" items

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found
Meta HTML wrapped in [wpv-items-found][/wpv-items-found] will be output if there are any posts | taxonomies | users returned by the View.
https://toolset.com/course-lesson/using-toolset-conditional-block/