Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 8 months, 2 weeks ago.

Author Posts
March 6, 2024 at 9:25 am #15378074

pavlinaD

Hi there,

We have 2 custom post types registered on our website - News & Insights and Case studies & White papers. The slugs to these URLs are as follows: /knowledge-hub/news-and-insights and /knowledge-hub/case-studies-and-white-papers. Our goal is to translate these pages into a second language, so the URLs will be respectively: /de/knowledge-hub/news-and-insights and /de/knowledge-hub/case-studies-and-white-papers

The archive pages for these 2 post types we've created using Elementor Pro's Theme builder functionality. Then, we're translating them using the following tutorial: hidden link. In addition to that, we've also tried translating them via the "Translations management" where we assign the theme builder template to a translator who then translates it from "Translations" (this method is not in Elementor's official documentation, but we thought to give it a try since the other one wasn't working).

This far everything works correctly - when we access the EN version of the page, the content is in English and when we access the DE version of the page, the content is in German. The issue comes when trying to switch between the languages via the language switcher:
1. When on the EN version, the lang switcher doesn't suggest there is another language version of this page: hidden link (FYI we're using the dropdown switcher).
2. When on the DE version, the lang switcher does display 2 different lang versions and correctly categorizes this page as "DE" (hidden link), but each of the languages in the dropdown links point to the respective Homepage of the website (i.e. DE is linked to domain.com/de and EN is linked to domain.com).

Some other things we've checked/tested:
1. In WPML -> Settings we have set this post type to be translatable and translated the URL: hidden link (since we want to keep the original English URL for DE too, we also tried leaving it to default)
2. Flushed permalinks, clear site & server cache
3. Having a page (WP admin -> Pages) with URL /knowledge-hub/news-and-insights and translating it to DE => /de/knowledge-hub/news-and-insights

Here's a screenshot of the CPT registration code: hidden link

Do you know how we can link the translations correctly? Any insight will help, thanks in advance!

March 6, 2024 at 4:58 pm #15380905

Nigel
Supporter

Timezone: Europe/Madrid (GMT+01:00)

Hi there

Before this is taken by a colleague, let me share some thoughts and get some more information.

It seems to me using Elementor to design the archive is something of a distraction, as that determines what is displayed at the archive URL, but it doesn't determine what the archive URL should be.

Do you have a staging server where you can do some simple testing?

Can you try disabling Elementor and using a default theme, such as twentytwentyone.

Make sure that you have news posts in the default and second languages.

Check that the archives display correctly (i.e. output the relevant posts) at their respective URLs for each language (e.g. .../knowledge-hub/news-and-insights/ and .../de/knowledge-hub/news-and-insights/), to confirm that the archives work as intended.

You should be able to check the language switcher on each page to see that it links to the correct URLs. Do they?

March 7, 2024 at 10:00 am #15383103

pavlinaD

Hi Nigel,

Thank you for following up on our query. Fortunately, we were able to find a solution and also fortunately - the issue we experienced had nothing to do with using Elementor's theme builder for the archive pages. It was pretty simple actually and all we had to do was translate at least 1 of the posts from this CPT into DE, then the translations of the two archive pages (EN & DE) got matched up correctly and the lang switcher is working as expected.

FYI, we did lead with your suggestion and tested w/out Elementor and with a default WP theme and just wanted to report that the result was exactly the same - as long as we didn't have at least 1 post translated into the secondary lang, the language switcher wasn't working correctly. Looks like this is only the case with archives for custom post types, because we didn't experience such issue with our blog archive which queries the content from the default Posts. So it is a matter of how WPML is built it seems, not an incompatibility or distraction caused by Elementor.

Hope this insight will be helpful to others as well. Have a good day.