Skip Navigation

[Resolved] single post template:display single posts custom fields as a select dropdown

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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by manousosV 4 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#2064769

Tell us what you are trying to do?I have a custom post type,lets say product,but it could be any.I use products as dishes..Each product(dish) has many custom fields wich i use to translate,lets say english,swedish,russian you name it.I want to display a select dropdown with each custom field as an option.I wanter also if it can be option groups,f.e asian languages,slavic etc and by choosing the group can display the related options..Thank you in advance..

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2065061

Hello and thank you for contacting the Toolset support.

To be able to hide or show something based on a dropdown selection, you will need to use Javascript custom code. This being said, the implementation will depend on how you implemented the custom fields.

Personally, I would create a Repeatable Fields Group with multiple fields:
- Language origin: this will serve as the group for languages.
- Language: this will hold the language.
- The options: this will hold what you want to hide/show based on the language selection.

First method
Then, I'll display this using two views on the legacy editor. Because the legacy editor will allow me to dynamically add a CSS class to the generated results.
Once view will generate the dropdown. To be able to group languages within the same language origin, you will need to order the view by that field, and implement a custom shortcode to group them. Check this article to see how to group results by a custom field https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

The second view will display the options and will wrap them inside a div that has a CSS class(let's use the language as the class, and we'll need to have it as a word, no spaces inside of it).

Then you can implement some Javascript code that will listen for the change event on the first view, and display the corresponding options from the other views.

Second method
I'll use one view that displays the language origin, the language, and the options. Then, using Javascript code, I'll build the dropdown, listen to the change event, and hide/show the corresponding options.

Read this article on how to create and display repeatable field groups.

However, you may implement a different design that won't require any custom Javascript code. For example, you can build an accordion using a 3rd party plugin that offers it. The Kadence blocks do offer an accordion block and they are compatible with Toolset.

I hope this makes sense. Let me know if you have any questions.

#2067445

My issue is resolved now. Thank you!