Hi! I have two post types that are connected by a relationship. Both types are translated via WPML. Things are currently set up so that if the related post exists in both the default (English) and translated (Spanish) languages, it shows up on both versions of the page. If the related post only exists in the default language, it shows up on the English version of the page but not the Spanish version. So far so good.
Now I'm trying to set up a relationship between two posts only in the translated language, not in the default - there is no English-language equivalent for the related post in this case. I found this thread - https://toolset.com/forums/topic/post-relationships-wpml-default-language/ - which seemed to imply that it should work if I create the related post in both languages but only connect it in the second language. But that doesn't work - if I connect the posts in English, it carries over, but if I only set the connection in Spanish, the related post doesn't show up at all.
What do I need to do to set up a working relationship only between the non-default / Spanish versions of the two posts?
Hi,
Thank you for contacting us and I'd be happy to assist.
Your observation is correct and by design, the post-relationships are defined between the primary language posts only, and no direct post relationship is maintained between secondary language posts.
The secondary language relationships are dependant on the post-relationship in the primary language posts too and the translation setting and translation status of the two primary language posts.
For this reason, you'll need to make sure that every post exists in the primary language and the relationships are also created between the primary language posts.
regards,
Waqar
Hi Waqar,
Thanks for the response. But, this is something we need to figure out how to do. Can you help come up with a workaround?
Basically, on hidden link, the boxes (For Kids & Families, Get a Library Card, Support Your Library, etc) are a content type called feature that is connected to the page content type. We need to be able to have a feature show up on hidden link that doesn't correspond to one on hidden link. It's fine if that feature has an English version in the database, but it needs to not actually show up on the page. Is there any way to do that?
Thanks--
Thank you for sharing these details.
If your goal is to make specific "feature" posts available only in a specific language, you can follow these steps:
1. You'll make sure that for each "feature" post, both EN and ES versions are available and the relationships are created with respect to the EN (primary) version.
2. You can add two new checkbox type custom fields "Available in EN" and "Available in ES" to this "feature" post, which will determine which feature post should be available in EN language and which should be available in ES language.
3. Next, whenever you need to show the list of "features" posts on the front-end, you can show them only in the allowed language, using custom code and conditional output.
You'll find a good usage example with a code snippet in this thread:
https://toolset.com/forums/topic/conditional-output-language/#post-402783
I hope this helps and please let me know if you need any further assistance around this.
Thanks, Waqar - that sounds like what I'm looking for! I'm going to test it out and will re-open this ticket if I run across trouble, but I think that will do it.