Skip Navigation

[Resolved] Using a parent post taxonomy in a child search view

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

Problem:
The user would like to filter a view using a taxonomy assigned to the parent post in a Toolset relationship.

Solution:
Actually, this is not possible. Toolset does not offer a way to filter a custom post type by the custom fields or taxonomies from a related post type. You can only filter with:
- The post's default(title, content, date, etc.) and custom fields.
- The post's taxonomies.
- ONE related post type in a Toolset relationship.

As a workaround, I'll suggest syncing the taxonomy from the parent post to the child posts. You can add a custom code, hooked to the save_post action, use the relationship API inside of it to synchronize the taxonomy assignment to the child posts.

Relevant Documentation:

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

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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by michaelS-53 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2105245

So we have two posts that share a parent-child relationship, one-to-many. These are "Games" and "Reviews.

We want to be able to use a category from Games called "Platforms" when searching for Reviews, but we can't seem to get it populated. We can bring in and display the drop-down, but it's blank.

Is there a syntax we can put in there like the item="@category-category.parent" or something?

hidden link

#2105545

Hello and thank you for contacting Toolset support.

Actually, this is not possible. Toolset does not offer a way to filter a custom post type by the custom fields or taxonomies from a related post type. You can only filter with:
- The post's default(title, content, date, etc.) and custom fields.
- The post's taxonomies.
- ONE related post type in a Toolset relationship.

As a workaround, I'll suggest syncing the taxonomy from the parent post to the child posts. You can add a custom code, hooked to the save_post action, use the relationship API inside of it to synchronize the taxonomy assignment to the child posts.
- https://developer.wordpress.org/reference/hooks/save_post/
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
- https://developer.wordpress.org/reference/functions/wp_set_post_terms/

I hope this helps. Let me know if you have any questions.

#2107039

My issue is resolved now. Thank you!