Skip Navigation

[Resolved] Conditional Display of Tabs

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

Problem:
How to apply conditional display on tabs? How to hide empty tabs in Layout?

Solution:
There is no option to put conditional on Tab titles. The workaround would be to add Tabs using Bootstrap tabs and then you can put your conditions on tabs title. Example bootstrap tabs code is given here:
http://getbootstrap.com/javascript/#tabs

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

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

This topic contains 2 replies, has 2 voices.

Last updated by Alan Murray 7 years, 5 months ago.

Assisted by: Noman.

Author
Posts
#537761
Screen Shot 2017-06-16 at 12.16.08 PM.png
Screen Shot 2017-06-16 at 12.16.23 PM.png
Screen Shot 2017-06-16 at 12.10.56 PM.png

I have set up a layout template for a custom post type. One section of the layout is a set of tabs. Some of the tabs display data that could be empty for some posts. I do not want the user to click on the tab only to get nothing, so I would like the tab only appear if there is something to show.

I read the information on Conditional Output in Views, including a video and saw several similar questions on this forum, including https://toolset.com/forums/topic/conditional-display-of-tabs-cont/. I understand the content of the responses well enough to duplicate it on my own site, I think, but I cannot figure out where to put the shortcodes they recommend.

If I click the edit button inside the tab, the Edit Visual Editor cell dialog (attached screenshot) comes up and I am able to successfully create a conditional statement that changes the content of the tab based on what is available in the dataset and this works, but it is not exactly what I want. I want the entire tab to disappear. I cannot get a similar dialog to come up for either the tab or the row, so I can't find a way to wrap the entire tab in a conditional statement. I've attached screenshots for the edit dialogs for the row and the tabs which do not allow me to edit the shortcodes or add conditional statements.

Is this possible? Where do I go to wrap the tab in a conditional statement?

#537839

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alan,

Thank you for contacting Toolset Support. There is no option to put conditional on Tab titles. The old threads are quite old and those solutions I believe appeared to work before Layouts and not for the Layouts tab cell (may be those were for Views tab shortcode).

The workaround would be to add Tabs using Bootstrap tabs and then you can put your conditions on tabs title. Example bootstrap tabs code is given here:
hidden link

Thank you

#537846

Thanks.