Skip Navigation

[Resolved] Filter nested View of child posts in a parent View

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

Problem: I would like to create a View of parent posts and add a nested View of child posts. I would like to include custom field filters on the front-end so Users can filter both parent and child posts.

Solution: It's not currently easy to accomplish this type of nested View with custom field filters applied to both post types. We expect to add more robust related post filters in an upcoming release.

This support ticket is created 5 years, 5 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.

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
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 6 replies, has 2 voices.

Last updated by culturaI 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1135139

Hello i read many threads but i cannot find a solution.

I'm using types 2.2.21

I have:
Parent post type: contatti
field1: "nazione"
field2: "sesso"

Child post type: corsi
field1: "livello"
field2: "tipo di corso"

I created a parent view (contatti) and inserted a nested view (corsi - Post relationship filter - Select posts that are a children of the current post in the loop.)

It's working good, i can display corsi for each contatto.

I can filter contatti fields (nazione+sesso).

I would to filter child posts in my parent views, so i could to display for example:
contatti filtered by "nazione" or "sesso", nested view corsi filtered by "livello" or "tipo di corso"

I'm missing something?

Thanks

#1136065
Screen Shot 2018-10-29 at 10.04.47 AM.png

Hi, Views custom search filters aren't designed to work well with nested Views like this. Usually custom filters are applied to a single View. Filtering a nested View is fairly complex, and requires some manual work. This approach does not work for AJAX Views or with the option "only show available inputs".
1. Create a View and choose the "Full custom display mode" option. Select Contatti for the content selection.
2. Scroll to the Search and Pagination editor and Add a Filter. Choose the nazione field, then repeat for the sesso field.
3. Click Add a Filter again, and choose the "livello" field. In the options for this field, choose a "Select dropdown" and "manually entered values" (see the screenshot). Then you must add all the options manually - one option for each option in the custom field.
4. Repeat the process for the "tipo di corsi" field, then add a Submit button.
5. Scroll up to the Query Filter section and remove the Query Filters for livello and tipo di corsi, because you do not want to filter the Contatti by these custom fields.
6. In the Loop Editor, add the post title shortcode.
7. Place the View on a page of your site, and you should see the View of Contatti with the 4 field filters.
8. Create a View and choose "Full custom display mode", and select Corsi in the content selection.
9. Scroll to the Search and Pagination editor and click Add a Filter. Choose the livello field, and the "select dropdown" type. This time, you do not need to add the options manually. Repeat for the tipo di corsi field.
10. Now delete the filters from the Search and Pagination editor, because the filter controls have already been added in the parent View. Keep the Query Filters in place.
11. In the Loop Editor, insert the post title shortcode.
12. Edit the View of Contatti and insert the View of Corsi in the Loop just after the post title shortcode.

#1136178

Thanks Christian, it worked like a charm!
Can i exclude from parent view a "contatto" with nested view empty?

#1136191

Not exactly, but you could remove the post title from the View of Contatti and add it to the View of Corsi inside the wpv-items-found shortcodes. This way the Contatti information is only displayed if child posts are found.

See how to use the post selection tab to display information from the parent post here: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

#1136248

Very good. One last question:
With types 3.0 i do the same steps to to obtain this result ?
I read here on forum ( https://toolset.com/forums/topic/display-parent-post-by-filtering-child-posts/ ) that new relationships (types 3.0) give or (will give in a short time) the ability to filter for related posts.
It is so or i misunderstood?

#1136284

Good question, there was some inaccurate information about this in the other ticket. Types 3+ does not include the related post field filters yet, but we expect the developers will add it soon in an upcoming release.

#1136285

My issue is resolved now. Thank you Christian!

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