Skip Navigation

[Resolved] Search: two fields in the same select option

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

Problem: I have two similar fields in different custom post types. I would like to use one filter control to filter both fields.

Solution: The only way you could filter both fields effectively is if the same field (same slug) is used in both post types. Otherwise, custom code is required and even then some Views features might not be supported. My best suggestion is to place the field in its own field group, and share that field group across both post types.

This support ticket is created 5 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Jaime 5 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1362003

Tell us what you are trying to do?
I have a CPT duplicated. Same fields.
I need to do like this because I need different roles to manage them and show differents Views.

But, in the search, I need to use one of the fields which is duplicated in the same select option.
I don't know how to reach this.

Example:
I have a field called "Province".
I have two CPT (CPT A and CPT B) with the field "Province" (same options, but actually they are different fields because they are from differents CPT).
I have a Search working which gives results for CPT A, but I need to include also the results of CPT B.

Is there any way to reach this?

Is there any documentation that you are following?
Not actually. I didn't found anything in the forum wich can solve my problem.

What is the link to your site?
You can see the search form working here
hidden link

#1362261

Hi, the only way you could do this without custom code is if the same field (same slug) is used in both CPT A and CPT B. Otherwise, you'll have to use custom code to manipulate filters with JavaScript. Even then, some features of custom search Views may not work correctly, like "only show available options for each input."

Is there an important reason why the same Province field cannot be used in both CPTs? What if you placed this field in its own field group, and included this field group in both CPT A and CPT B? It seems like that would be a good solution to this problem.

#1363265

My issue is resolved now. Thank you!