Skip Navigation

[Resolved] filter view by post relationship field/taxonomy

This support ticket is created 3 years, 11 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/Karachi (GMT+05:00)

Author
Posts
#1919805

Hi,

The content type "Translator profile". This has a relationship with the content type "Skills".
The "Skills" fiels are only categories (Translation Type, Origin Language, Destination Language).

I have a view which shows the Translator profiles list. When I configure the filters search, I try to use the categories Translation Type, Origin Language, Destination Language from Skills related but this not work.
Also, I tried the search filter "post relationship or repeatable field groups owner", but it only allows show the Skill post title.

How can I filter the search based on post of relationship fields (taxonomies)?

Thanks

#1920029

Hi,

Thank you for contacting us and I'd be happy to assist.

Your observation is correct and the search filters in a view can only be used for the custom fields and taxonomies, which are directly attached to the selected post type and not through the ones which are attached to the related posts.

Is there any special reason, you're using a "Skills" post type, separately? Based on the description and the requirement you've shared, it would make sense to attach those three taxonomies directly to the "Translator profile" post type.

regards,
Waqar

#1920169

Hi, Waqar,

I'm using a "Skills" post type separately because "Translator profile" needs a repetitive group fields with those three values, but Toolset don't allow do ir with category fields. And, I use categories instead select fields because they can be edit easilier (the web editor could add and remove items easilier), by example, add/remove/alter languages (terms) on the Origin and Destination Language.

For example:
- John Doe has the skills
- - Translation, German to English
- - Translation, English to German
- - Translation, Italian to English
- - Sworn translation, German to English
- - Sworn translation, English to German
- - Correction and revision, Italian to German
- - Translation Type, Origin Language, Destination Language

- How can I do it by the other way?
- Can I create those three fields (Translation Type, Origin Language, Destination Language) like selects easy? The best way would be value/items to be easily editable by the web editor. When I tried to create them by this way (selector fields in repetive groups inside CPT "Translator profile"), I had have to copy and paste the 200 languages duplicate is each field (Origin and Destination Languages) on custom fields edit.

Thank you very much

#1920339

Thank you for sharing these details.

Why not use just one taxonomy "Skills" with the post type "Translator profile" and then add all possible combinations of "Skill type, Origin Language, Destination Language", as an individual term in that taxonomy.

Based on personal preference, you can either use the flat/non-hierarchal structure for the terms, e.g.

- German to English Translation
- German to English Sworn translation
- German to English Correction and revision
- English to German Translation
- English to German Sworn translation
- English to German Correction and revision
and so on...

Or the hierarchal term structure, e.g.

- German to English
-- German to English Translation
-- German to English Sworn translation
-- German to English Correction and revision
- English to German
-- English to German Translation
-- English to German Sworn translation
-- English to German Correction and revision
and so on...

This should be easier to manage from the administrator's perspective, you'll also be able to use the front-end search filters and it will also have performance benefits, as the query will be simpler.

#1920493

Hi, Waqar,

The hierarchical category system you propose would be: Origin languace (1st level) > Destination Language (2nd level) > Type of translate (3rd level).

But there are a total 200 languages (from ISO 639).

The option to create in the "Translator profile" a unique structure of hierarchical terms is unfeasible because need to create huge duplicates: combination of 200x200 languages x 4 types of translation = + - 16000 lines (I guess) and in the best case 50x50x4=10000.
And if you wanted to create a new language it would mean manually creating 800 more category lines.
And if I create a new type of translation, I will have to add it in the third level ('destination language' son) of 4000 categories (second level).

Is there another alternative?

I can’t figure out how to approach Toolset to an attractive solution for this system.

#1921449

Thanks for writing back.

A workaround may involve some customization, but, I'll need to understand how the "Translator profiles" are added and edited on the website.

Will they added/edited by the admins only from the back-end or the users would also be allowed to add/edit their own "Translator profiles"?

#1921525

Hi,
the users would also be allowed to edit.

#1922779

Thank you for confirming that.

I'll need to perform some tests and research on my website, to suggest some workaround.

This will take some time but, I'll keep you updated through this ticket.

#1922905

Thank you very much.
Your help is very important.

#1925301

Hello, Waqar,

I was thinking of two shortcut alternatives. Don’t take them into consideration if you see that they are not useful to you or if you know already a more successful solution.

One: Create a search filter on the "Skills" titles (already a CPT related in the "Translator profile"):
- Each "Skill" is automatically assigned a title when it is saved (non-customizable and not publicly visible) in this pattern "[A] Translator code [B] Translation Type code [C] Origin Language code [D] Destination Language code", example: "[A]934 [B]3 [C]eng [D]esp".
- Create in the view three select filters (Translation Type code, Origin Language, Destination Language) that all searched on the title of the "Skills" related in the "Translator profile".

Two: Add a group of repetitive fields (Translation Type code, Origin Language, Destination Language) to the "Translator profile" custom fields:
- In the "Translator profile" edition, dynamically load the values ​​of Origin Language, Destination Language (remember that there are a minimum of 100 languages).
- The problem with this proposal is that I can't load the values ​​dynamically into the search filters. And if I cheat it for a test, it fails to do the research in the repetitive fields.

Thanks again

#1929117

Thank you for waiting and for sharing those suggestions.

Just wanted to let you know that I'm still doing some testing and will be able to share my findings with you by the end of the day today.

Thank you for your patience.

#1931387

Thanks, Waqar. I am on a dead end in Toolset capabilities.
It would be very interesting for Toolset to have in the views the possibility of filter by related posts fields.
Or that repetitive fields (in selects) could load values dynamically, not manually, in a natural way.
I hope to see some light on this path...
Thanks again for the great support

#1932719

Hello,

Waqar is on vacation, I will take care of this thread.

In your case, I think there is easy workaround, here are my suggestions:
1) Create a custom post type "Translator profile"
https://toolset.com/course-lesson/creating-a-custom-post-type/

2) Create a custom taxonomy "Skills", and register it to above post type "Translator profile"
https://toolset.com/course-lesson/creating-a-custom-taxonomy/

So you will be able to setup view block:
- Query "Translator profile" posts
- Filter by "Translator profile" terms
https://toolset.com/block-item/view/
https://toolset.com/documentation/user-guides/views/filtering-views-by-taxonomy/

You can also add custom term fields to taxonomy "Skills"
https://toolset.com/documentation/user-guides/views/term-fields/

And use WordPress archive to customize "Skills" term archive page:
https://toolset.com/course-lesson/creating-a-custom-archive-page/

#1932849

Thanks for your answer, Luo. But it seems
Previously, in the messages from January 27, 2021 at 9:07 am, I explained why It is not possible that solution: It is necessary three fields for each skill (type of translation, original language and destination language), and each language field contains hundred items.
It is the first time I use Toolset, and I like it, but I need to know if it is really the right CPT tool for this project.
Thank again for you help.

#1934539

Toolset Views/Blocks plugins are using WordPress built-in class WP_Query to query posts, so if you are querying "Translator profile" posts, you can only filter the results by custom fields/taxonomies of same post type "Translator profile", you can not filter the result by custom fields/taxonomies of other post types("Skills"), this is the limitation of WP_Query, see WP document:
https://developer.wordpress.org/reference/classes/wp_query/

And Toolset repeatable field group is based on one-to-many relationships, so in your case, if you insist on the content type "Translator profile" + "Skills" + repeatable field group of "Skills", there will be three post types involved:
- Translator profile
- Skills
- repeatable field group of Skills

And in order to achieve what you want, it needs nested views, for example:
1) Parent view
- Query "repeatable field group" posts
https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
- Filter by custom fields of "repeatable field group"
- In view's loop, display a content template with "item" attribute, use this content template to display parent "Skills" post information + below child post view:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

2) Child post view:
- Query "Translator profile" posts,
- filter by post type relationship between "Translator profile" and "Skills"
- In view's loop, display "Translator profile" post information
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

For your reference.