Skip Navigation

[Resolved] Filter view to display UNIQUE custom field values

This support ticket is created 3 years, 10 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
- 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 5 replies, has 2 voices.

Last updated by jamesR-13 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1909579

Tell us what you are trying to do?
Filter view to display UNIQUE custom field values

to explain further: I have a list of 'employees' each employee is assigned a 'division' as a custom field value. I am trying to build nested views that shows a list of each division with a list of employees belonging to that division right below it. How do I make a view that lists the unique VALUES of the division custom field for employees?

I can make a view that lists every employee's division field value, but I just want the field values listed, not the employees.

This is probably a lot simpler than I am thinking it is... or maybe I have my data structured incorrectly. Do I need to make 'Divisions' a taxonomy maybe? Or is there a way to list only UNIQUE values for a field?

#1910171

Hello,

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example:
https://stackoverflow.com/questions/58026099/get-a-list-of-custom-field-values-limited-by-post-category

If not too much values in that custom field, you can consider to pass the field value manually to child post view, see our document:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

#1910687

hmmm....

I have been making a lot of use of passing arguments, but I am struggling to understand how to use that to accomplish what I am after here.

Maybe I should explain differently, maybe there's a different solution.

I want to return only the FIRST instance of each value for the field. Is that possible? Like how if you make a custom search filter checkbox based on a text field, you end up with a checkbox for each value that is entered into the field. Can I do something like that with a passed argument? If so, how?

#1911341

I only have 13 values, and doubtful it would ever go over 20.

#1911411

As I mentioned above, there isn't such kind of built-in feature, you will need to consider custom codes or pass the field value to view's shortcode manually :
https://toolset.com/forums/topic/filter-view-to-display-unique-custom-field-values/#post-1910171


Like how if you make a custom search filter checkbox based on a text field, you end up with a checkbox for each value that is entered into the field.

That is for custom search form, it does not work for your case.

#1936199

I was able to accomplish this by taking the field data and making it a taxonomy instead.

Then I made a view that lists taxonomies, and in the loop template, I nested another view that lists the loop items and set the query filter to taxonomy.