Skip Navigation

[Résolu] Can I Display a Parent Type after Using Parametric Search for Child Fields

This support ticket is created Il y a 7 années et 10 mois. 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 1 réponse, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 10 mois.

Assisted by: Luo Yang.

Auteur
Publications
#409069

I’m not sure if this is possible with Toolset. From what I’ve seen, there are similar questions but no simple example that I can find of how to do this. I will attempt to describe my setup and the goal of the search function on my site:

SETUP:
I have a custom parent type called New Construction Home.
It has child post types called Models.

The parent post type displays all of the models on the parent content template page. Everything looks and works great there.

I am trying to create a parametric search that would allow users to search for details that are only found in the custom fields of the child posts (models) but will display a list of the parent post types as the search results (loop output).

From the support threads I’ve found, the only way to do this is to use the loop output to display the parent fields for each child that meets the criteria, which would result in many, many duplicate listings in the search results in our case. Is there a way to set up a parametric search that uses custom fields from the child post type even when the "Content Selection" is the parent post type?

Thanks,

Marcus

#409202

Dear Marcus,

There isn't such a feature within Views plugin.
Since Views is using wordpress class WP_Query to query to posts, so all custom fields and custom taxonomies should be setup in the post type you are going to display:
http://codex.wordpress.org/Class_Reference/WP_Query

And one parent post can have multiple child posts, so the problem occurs as you mentioned:
which would result in many, many duplicate listings in the search results.

In your case, you can try add your custom filters with Views filter hook:
https://toolset.com/documentation/user-guides/views-filters/
wpv_filter_query
Filters the main Query in a View displaying Posts

But it needs some custom PHP codes, you can check out our certified partners for it:
https://toolset.com/consultant/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.