Skip Navigation

[Resolved] Is there a way to filter parents on the taxonomy attached to it’s children?

This support ticket is created 8 years 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)

Author
Posts
#390157

The situation:

Parent > Book
Child > Review
Taxonomy (Hierarchical)
- Tag A
- Tag B
- Tag C

The Book page lists all added reviews. Users can add multiple tags to those review.

The homepage lists all books. Now i’m curious if there is a way to filter books on the taxonomy attached to it’s reviews.

Example situation:

Book #1
Review #1 [Tag(s): A + B]
Review #2 [Tag(s): A]

Book #2
Review #1 [Tag(s): A + C]

Book #3
Review #1 [Tag(s): A + B + C]
Review #2 [Tag(s): A + B + C]

So I added three books to the website and want to find the ones with tags A + B attached to it’s reviews.

The results should show me Book #1 and Book #3.

I tried the below approach from Luo Yang but this solution will show Book #3 two times for the above situation because it has two reviews both with the tags A + B.

https://toolset.com/forums/topic/parametric-search-results-from-post-children/

#390417

Yes, you are right, since one parent "Book" post can have multiple child "Review" posts,
When you are using Views to query the child posts and display it's parent "Book" post, it will produce the problem:
There will be duplicate "Book" posts in the result.

And there is a workaround with custom codes:
you can use Views filter hook wpv_filter_query_post_process, to remove the duplicate items:
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query_post_process/

But it won't work as expected when you using Views pagination.
For your reference.

#391054

Ok, clear. To bad, pagination will be necessary of course.

Is there another overall structure workaround for making it possible to search for books that has reviews with certain tags? (don't need to be taxonomy, just the ability to add one or multiple tags to a review)

#391231

In your case, there isn't other better workaround without custom PHP codes, I suggest you contact our check out our certified partners for it:
https://toolset.com/consultant/

#391260

Ok, tnx Luo Yang!

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