Skip Navigation

[Resolved] Radio button select

This support ticket is created 5 years, 9 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#1183499

Hi!
I have a custom field with radio button.
I need to create separate views views that shows me all the results that has a radio button selected.
For example, if I have radio button with A, B, C i need to create 3 views: One with all A results, one with all B and another with all C results.
There is a way to do it? How can I create a filter inside views to do it?

#1183553

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Your custom radio field will store a value, depending on whether option A, B, or C was selected when the post was saved.

So you will filter a View based upon that value.

Let's say my custom field is 'status', and the values stored for the options "active", "inactive", and "archived" are simply 1, 2, and 3.

So I create a View to query the post type in question, and add a Query Filter for the status field. If you can't see the Query Filter section, go to the Screen Options tab at the very top of the page and make sure the Query Filter option is checked (it is hidden by default when you create a custom search View, for example).

Now, in the UI dialog where you insert this filter, you could manually specify that status should equal 1, and then make another View for when status = 2, and a third View for when status = 3.

But if the Loop Output sections are largely the same in each case, then it makes more sense to set the value using a shortcode attribute, as described here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/, so that you create just one View, but when you insert the View somewhere on a page you add a shortcode attribute to specify the required value.

(When you choose shortcode attribute while inserting the filter, it will suggest a default for the attribute name, but you can change this to whatever you want, just be sure to specify the same attribute when you insert the View shortcode.)

Note that there are some contexts, if you are inserting a View via a page-builder widget, for example, where you cannot specify a shortcode attribute, and in such cases you would instead need to insert the View using a shortcode (the Fields and Views button if available would output the correct format) and then manually add the attribute to the shortcode.