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.

This topic contains 3 replies, has 2 voices.

Last updated by Bobby 4 months, 1 week ago.

Assigned support staff: Bobby.

Author Posts
June 10, 2019 at 7:34 pm

klimeM

I am trying to:
I have a page in 3 languages, first I created the Macedonian one, than I installed WPML and added English and Albanian. For some of the pages I have created a php file with id, like page_xx.php. I have translated the content of the page in WPML but when I check it in English or Albanian it's translated but it's not taking that template defined by page_xx.php. I have enabled the 'Make themes work multilingual' checkbox in the first place.

Link to a page where the issue can be seen:
For example take page_33.php, the original link in Macedonian is : hidden link (cyrilic encoding), in English : hidden link and Albanian : hidden link
You can notice that original page in Macedonian has a sidebar which is defined in page_33.php but it's not used on English and Albanian. Let me know what I am doing wrong because I used WPML before and this was not happening.

I expected to see:
Explained above 🙂

Instead, I got:

June 10, 2019 at 8:28 pm #3990263

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

If i understand correctly you have defined a page template and then you parse the page id for the template to take place?

note that each translation has a different page id , you can find the page ids by clicking on the default language page and then using the language switcher to switch to the secondary language

this will ensure you remain within the page builder view, on the top in the URL you will be able to see the page ID

additionally this way you can verify the settings in each language to make sure they are set correctly

let me know your results please

June 10, 2019 at 9:25 pm #3990473

klimeM

Hello Bobby, thank for the quick reply. Is there some way I can make one page template that will be used by all 3 languages, because inside I use string translations and if I want to make some small change to the template I will have to make it in 3 page templates (If I use ID)?

June 10, 2019 at 11:24 pm #3990721

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

As a test i used your FTP credentials , went to your page templates and duplicated page-33.php then renamed the new one to page-1409 ( i have added .deactivated next to it within the FTP so it wont show on your live site, but it is there if you want to test it)which is the id for the Albanian version of that page and as expected the sidebar came up.

There are 2 things that will need to be addressed here

1. If you are planning on translating these strings say from Macedonian to Albanian for example without trying to make the translations hardcoded(thats if you use only one page template) then you will need to wrap your strings in a gettext call so String Translations can pick them up and allow you to make translations

-> https://wpml.org/faq/language-setup/

2. To only use one template for all page you will need to make sure that it grabs the id of the post rather than parsing the Id through the name of the file "ex. page-33.php"

this will require change in your code

i personally believe this is an expected behavior as a different template is expected per page as discussed here [please review the solution another user has used]
=> https://wpml.org/forums/topic/page-templates-not-working-in-translated-languages-eg-page-about-us-php/

i recommend reviewing our WPML hooks library

https://wpml.org/wpml-hook/wpml_object_id/
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

Please note that at the moment we cannot provide custom work within the forum , but we do recommend using our 3rd party WPML contractors if custom work is needed
-> https://wpml.org/contractors/

The topic ‘[Closed] Translating the pages with ID’ is closed to new replies.