Skip Navigation

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

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.

This topic contains 1 réponse, has 2 voix.

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

Assigned support staff: Luo Yang.


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:

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?




Luo Yang

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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:

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:
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: