I am using a nested view to loop through children of a parent post in order to return taxonomy terms associated with the child posts.
Relationship (many to many) is as follows:
- Book Series << Series Number >> Audio Book
- Audio Books are associated with the taxonomy titled 'Author'
Because some of the child posts are tagged with the same taxonomy term, the loop outputs duplicates of the same term. Example:
Book Series A (parent post page)
>> Audio Book 1 (child) >> Author 1 (taxonomy term)
>> Audio Book 2 (child) >> Author 1 (taxonomy term, duplicate)
>> Audio Book 3 (child) >> Author 1 (taxonomy term, duplicate)
How can I skip or remove the duplicate terms?
Hello,
Since the taxonomy "Author" is in post type "Audio Book", and you are querying the "Audio Book" posts, so it is expected result:
there will be duplicated "Author" terms
You might consider to register the taxonomy "Author" to post type "Book Series", then display the result with a nested view:
1) Edit each "Book Series" post, setup taxonomy "Author" terms.
2) Create the parent taxonomy view:
- Query terms of taxonomy "Author"
- Filter by a "Taxonomy filter":
Select posts with taxonomy:
Authors the same as the page where this View is shown
- In view's loop display the "Author" term's title + below child post view.
3) Child post view:
- Query "Audio Book" posts
- Filter with:
a) Post type relationship filter: Select posts in a Series Numbers relationship that are related to the Post where this View is shown.
b) Taxonomy filter:
Select posts with taxonomy:
Authors set by the parent Taxonomy View
- In Views loop, display the "Audio Book" post information
4) In single "Book Series" post, display the parent taxonomy view of step 2)
More help:
https://toolset.com/documentation/user-guides/views/using-a-child-view-in-a-taxonomy-view-layout/
Hi Luo,
Thanks for your description. The issue here is that not every Audio Book in a series has the same authors.
If the taxonomy is associated with the Book series (parent) rather than with the audio book (child), how can I define which authors are related to which book?
I am hoping to display the aggregate total of authors associated with any audio books of a series, instead. Is there a way to do this while skipping over any duplicate posts?
Q1) how can I define which authors are related to which book?
You can register to taxonomy "Author" to both post types:
- Book Series
- Audio Book
But you will need to setup "Author" terms in each "Book Series" and "Audio Book" post.
Q2) Is there a way to do this while skipping over any duplicate posts?
There isn't such kind of built-in feature within Toolset plugins using your website existed settings, as I mentioned above:
Since the taxonomy "Author" is in post type "Audio Book", and you are querying the "Audio Book" posts, so it is expected result:
there will be duplicated "Author" terms
you might consider the workaround I mentioned above.