Skip Navigation

[Resolved] Different Layout Templates for Custom Post Type translated with Polylang

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

Problem: I have created a Layout that I want to apply to a custom post type. I am translating posts with Polylang, and I would like to show translated posts with a different Layout.

Solution: Instead of using different Layouts, use Polylang's string translation functions to translate specific content in the Layout.

Relevant Documentation:
https://letswp.io/easily-translate-input-texts-wpml-polylang/

This support ticket is created 5 years, 3 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by terryR 5 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1189713

Hello,
I would like to ask you for advice about setting up different templates to be used on same post type.

(Example)
The situation is:
1. Products (Post Type) - 2 different categories in the Product Category assigned ( one is for English and the other is for French )
2. Layout Template built - The default one has labels in English and second one was duplicated but using labels in French

I tried manually to assign the French Layout Template to be used on each french post only.
But the Layout affects globally all of the Posts in the CPT including the English ones.

I checked the Option in the Layout of "Change how this template is used" and tried to find an option for filtering Post Type by categories assigned ( something similar to the Views filtering function ) but I haven't found one.
And not sure how to isolate the English and French products by using 2 different ayout Templates with their proper language template assigned.

I attach snapshots for better understanding of the issue.
I really hope that you can help me there.
Thank you, appreciate it.

Best Regards!

#1189861

Okay after a bit more investigation here I believe I have a solution. Rather than creating multiple Layouts for different languages, you can use Polylang's string translation system to translate individual strings in one Layout. This means you can reuse the same basic Layout design, but translate text in individual Visual Editor cells independently. Here's an article that talks a bit more about registering strings for translation in Polylang:
https://letswp.io/easily-translate-input-texts-wpml-polylang/

With WPML, you can simply wrap the contents with a wpml-string shortcode to register those strings for translation. Polylang is a bit different, and the article above shows you how can create a custom shortcode to perform a similar function. Once you register the strings for translation, you can go to Polylang's String Translation system to translate each string.

#1189921

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.