Skip Navigation

[Resolved] Search by select field of related CPT

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

Problem:
We have two related CPTs - Resources & Resource Items (1 Resource - many Items). Each individual Item has a select field to indicate an associated language.

We present users with a Resources page where they can search on various aspects of Resources and would like to add the ability to search for Resources according to which languages they are associated with via their related Resource Items.

Solution:
Currently, Toolset does not allow to filter a custom post type by custom fields on a related post type. This feature is on our list and will be added in the future, but we still don't know when.

It is worth mentioning that this can be implemented with custom code. It will need custom code to build the filter and another custom code that can use the toolset_get_related_posts function and hook into the view's wpv_filter_query query filter.

Relevant Documentation:

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

Last updated by Michael 4 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#1858371

I suspect this is not uncommon but can't seem to find quite the right answer via support search.

We have two related CPTs - Resources & Resource Items (1 Resource - many Items). Each individual Item has a select field to indicate an associated language.

We present users with a Resources page where they can search on various aspects of Resources and would like to add the ability to search for Resources according to which languages they are associated with via their related Resource Items.

#1858705

Hello and thank you for contacting the Toolset support.

Currently, Toolset does not allow to filter a custom post type by custom fields on a related post type. This feature is on our list and will be added in the future, but we still don't know when.

It is worth mentioning that this can be implemented with custom code. It will need custom code to build the filter and another custom code that can use the toolset_get_related_posts function and hook into the view's wpv_filter_query query filter.
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

Please note, that custom code is beyond the scope of the support forum.

I hope this answers your quesiton. Let me know if you have further questions.

#1858707

That's useful, Jamal - thanks for the quick response 🙂

#1858709

Thank you, Michael!

I'll set this ticket as "I think it is resolved", if you don't have any further questions, please mark it as resolved and open a new ticket for any other question/request.

#1861151

[ignore this .... robot link took me to wrong support ticket!]

Just pinging here in response to your 'cleanup robot' ...

#1861155

My issue is resolved now. Thank you!