Skip Navigation

[Resolved] Synchronized with the title field of the related posts?

This support ticket is created 2 years, 2 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by patrickM-3 2 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2493271

I have 3 post types: Products, Cases and Items.

A Product is a case filled with a quantity of items. I need to display products but allow users to filter by Item fields. The particular fields I'm using for filtering are relatively short strings.

I realize that I cannot filter on fields and taxonomies of my view's post type. But, wouldn't it be possible to make a taxonomy on the main post type who's terms simply stayed synchronized with the title field of the related posts? If each item has a field called 'Item Variety', I would add a taxonomy to Products called Item Variety. It's terms would be all of the unique strings among the Item Variety field and each product would have the taxonomy that matches the Item Variety field.

I could manually generate the list of unique terms from the Item Variety field and manually create a taxonomy for products with those terms. I could then create a view that would set the taxonomy of each product to match the values in the Item Variety field for all the items in that product. I would then be able to filter products based on that taxonomy.

It seems like there should be a relatively easy way to instruct Toolset to take a field from a post type and generate unique taxonomy terms that it would assign to another post type. This may already be possible using Toolset Relationships, but I don't know.

Looking into this further, I already have 2 Toolset taxonomies created for Items: Item Variety and Item Packaging. I can assign both of those taxonomies to both Items and Products.

Then, when I add Items to a Product, I need to select the same Variety and Packaging for both the product and the items in the product. Then my product view would be able to filter on Variety and Packaging - essentially do a parametric search.

I already have a relationship between Products and Items. Isn't there a way to automatically set the taxonomy for the Product to match each time I connect a product to an item?

#2493275

Hello,

Unfortunately, there isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example:
When user save "Items" post, use action hook "save_post" to trigger a custom PHP function:
https://developer.wordpress.org/reference/hooks/save_post/
in this PHP function:
1) Get the related "Products" post information:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
2) And save those taxonomies into "Items" post
https://developer.wordpress.org/reference/functions/wp_set_post_terms/

#2493845

My issue is resolved now. Thank you! Sorry about opening a second ticket. Must have been working late.