Skip Navigation

[Resolved] view that brings results without repeating

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2579955

Hello everything is fine?

in my project, I need to create a view that has a filter by custom field.

However, the result of this view can only bring unique results, that is, it cannot bring repeated posts.

Ex: My Posts:
id - name - slug - custom_field
1 - car - car1 - a
2 - car - car2 - b
3 - car - car3 - b
4 - car - car4 - c

The result of the view, just to be:
1 - car - car1 - a
2 - car - car2 - b
4 - car - car4 - c

How can I do this?

I'm waiting.

Thanks

#2581391

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I will have to look at and review what structure you build and how you configure you view. If the custom field belongs to parent post type and the result you are displaying is belongs to repeating field group?

Can you please share problem URL and admin access details and let me review your structure and guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2581445

actually this is a view that I haven't built yet.

but my idea is this:

imagine that I have any CPT, and that it has a custom field called "custom_field_a", with dozens of registered posts.

now imagine a view with a text filter that filters by custom_field_a.

my idea is to change the text type filter, for a select type filter, this new filter is made in html itself and in place of the options, I call another view that will bring only the unique results that are entered in the search for field values custom_field_a.

so the user no longer needs to type the information he needs, he simply selects the options he has.

did you get it?

#2581455

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

so if you go for select field, yes, it will display only results where the selected option is matched exactly. You should try and test it.

#2581467

yes... but the question is:

imagine that my CPT is "cars" and the custom_field_a is "car brand" and I have dozens of Ford cars registered.

In the filter select options, I will have dozens of "Ford" as filtering options, but I only want 1 value.

did you get it?

#2581473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you want to have only one option why you are going with select dropdown I'm not sure as users will not have luxury to change the option.

Also, there is no way to delete other options from custom field select as it will display all the options. In such a case you may have setup taxonomy and add a taxonomy filter and you can control what terms you want to display with your taxonomy filter using the following view's filter hooks:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_get_terms_args