Thanks a lot Luo and please excuse me for insisting so much on that but replacing Toolset relationships with another kind of linkage is not something I wish to do before I am absolutely sure it's impossible to get them working as needed for this project because I will loose a lot of comfort doing so.
On my side, i did a bit more testing and discovered that I could manage to connect, disconnect and display relationships correctly in the backend using :
function disable_relationships_filtering( $query ) {
$query->query_vars['suppress_filters'] = true;
if ( is_admin() && !$query->is_main_query()) {
do_action( 'wpml_switch_language', "fr" );
}
}
add_action( 'pre_get_posts', 'disable_relationships_filtering' );
But that's really not an ideal solution so it would be great if I could find a workaround that would only affect relationships related queries while not needing to switch language along the way.
Have a nice weekend.
Here is the feedback from our developers:
It is not possible within the Types plugin, and this is a limitation of WPML option "Translatable - use translation if available or fallback to default language", we don't have other existed workaround for it.
If you agree, we can take it as a feature request.
Well, I think that being able to allow relationships to be set and displayed regardless of post languages may be useful in many cases so taking it as a feature request would be a good thing even if useless for me in the context of the current project which has to go live in December.
So if I am not misunderstanding, actually my options are :
1) Completely replace Toolset Relationships for linking posts (custom code, other plugin, etc.)
2) Try to go with the solution I mentioned in answer #2208745 but I will then probably get stuck for frontend display
3) Work with both post types set as not translatable and use a custom field to filter them by language
I guess I should give a try to the third option before replacing Toolset relationships even if I would then probably have to solve a few problems with frontend display.
Could you please tell me if relationships would work correctly this way at all levels even though many of the posts have been created as secondary language posts and have no default language translation ?
Please check the document I mentioned above:
https://toolset.com/course-lesson/translating-related-content/
The post type relationship works when you setup both post types as "Translatable - only show translated items", it works when you connect posts in same language.
Hope it is clear
Well, I am not sure it's completely clear but at least enough for me to understand that relationships are useless in my context and that the best thing I can do now is stop wasting time on it.
Thanks for your help and patience.