Skip Navigation

[Resolved] Cannot filter results by custom field from child relationship

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

Problem:

Filter a post view by custom fields of another post type.

Solution:

Relevant Documentation:

It is a limitation of WordPress PHP Class WP_Query: if you are going to filter posts a custom post type by custom fields, those custom fields should be setup in this custom post type, you can not filter the result by custom fields of another post type.

0% of people find this useful.

This support ticket is created 5 years, 8 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by graemeS 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1214039

I am trying to: Filter results based on a custom field (Bedrooms, Bathrooms, Living, Cars) which are located in the Designs CPT.

Link to a page where the issue can be seen: hidden link

I expected to see: A select drop-down showing the room numbers being displayed the search results currently being displayed in a basic output using [types field='bedrooms' item='@home-design_house-and-land.parent'][/types]

Instead, I got: A blank select box.

#1214063

Hello,

Thanks for the details, I can login into your website and see the problem.

Please check the custom field group "Home_Design - Rooms" setting here:
hidden link
Those custom fields (Bedrooms, Bathrooms, Living, Cars) are registered to Post Type "Home Designs".

But the post view "Parametric_Search_House_Land View" is querying posts of another post type "House_Land Packages", since there isn't custom fields (Bedrooms, Bathrooms, Living, Cars) in "House_Land Packages" posts, so it conducts the problem you mentioned above: A blank select box.

It is a limitation of WordPress PHP Class WP_Query: if you are going to filter posts a custom post type by custom fields, those custom fields should be setup in this custom post type, you can not filter the result by custom fields of another post type.

So you might consider to move field group "Home_Design - Rooms" to post type "House_Land Packages", edit each "House_Land Packages" post, and setup those custom fields values.

#1214084

The goal desire is to save on data entry by connecting the designs to the packages so the lack of that ability is a bit of a pain - can it be achieved with custom php? Any suggested experts who could achieve it?

#1214092

It should be possible with custom PHP codes. and nothing is impossible with custom codes, you can check it with our Toolset Contractors:
https://toolset.com/contractors/

You can also add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Our developers will evaluate it.

#1214203

There now seems to be a "Bug" with my View (Parametric_Search_House_Land View)

When displaying only the results, it is adding an old edition of the search filters at the top and becoming unresponsive?

hidden link

You can see both the "filters" being out put when the bottom should only be showing the results.
[wpv-view name="my-landy" view_display="layout" cached="off"]

#1214489

Assistance with this issue available?

#1214495

I have rebuilt the view, page. It's now possible to use the "search / filters" once - only via submit button action, not via "AJAX" and it only works once, after that it no longer functions.

#1214499

My issue is resolved now. Thank you!

blah