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/
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.
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)
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/