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 8 replies, has 2 voices.

Last updated by Noman 1 year ago.

Assigned support staff: Noman.

Author Posts
October 2, 2018 at 10:34 am

Jacques David

I am trying to: Use get_permalink to get the URL of a translated page URL while having the "Adjust IDs for multilingual functionality" enabled in the footer.php

Link to a page where the issue can be seen: hidden link

I expected to see: In the Footer, for the link "Qui sommes-nous" the URL to be hidden link

Instead, I got: Link is hidden link

Note Duplicator isn't working on our server (Throws a 503 Error). Instead we gave a Cpanel backup, hope this is acceptable?

October 4, 2018 at 7:42 am #2786571

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. I have tried to login to your site but wp-login info needs "Login Authentication Code" and FTP info that you have provided is not working here. Could you please try to use the wpml_permalink hook and let me know if that helps. https://wpml.org/wpml-hook/wpml_permalink/

Thank you

October 4, 2018 at 8:46 am #2786723

Jacques David

Hello,
I've temporarily disabled "Login Authentication Code" now and enabled the Editor in Appearance > Editor which should allow you to login and edit stuff.

We also tried "wpml_permalink" hook but it didn't work.

Code is in footer.php

Let us know ?

Thanks

October 4, 2018 at 1:32 pm #2787680

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

I have fixed this issue by using ‘wpml_object_id’ hook and updated following code:

<?php echo get_permalink(6); ?>

With:

<?php echo get_permalink(apply_filters( 'wpml_object_id', 6, 'page', false, ICL_LANGUAGE_CODE )); ?>

Now it showing correct translated URL. Could you please check and confirm?

Here is doc for more details:
https://wpml.org/wpml-hook/wpml_object_id/

Thank you

October 4, 2018 at 2:30 pm #2787821

Jacques David

Thanks
But why is it not working with the setting "Adjust IDs for multilingual functionality" enabled as it should with just get_permalink without having to use wpml_object_id filter ?

And will this filter still work in the future ? Or will it be deprecated?

Thanks

October 4, 2018 at 5:36 pm #2788405

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

During my first test wpml_permalink hook did not work. I will do some further testing and will escalate it to our 2nd tier support accordingly.

In the meantime you may use the other code I have provided.

Thanks

October 9, 2018 at 7:09 am #2798506

Jacques David

Hello,
Any news from "2nd tier support" team on this issue ?

Thanks

October 9, 2018 at 12:13 pm #2799891

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello, No updates on this issue at the moment. I will update you as soon as we have some news on this.

Thank you for your patience and cooperation.

October 9, 2018 at 3:21 pm #2800759

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I have done some more testing on this and tried to reproduce issue using get_permalink filter again in WP default theme (e.g. Twenty Sixteen) and its appear to be working fine. Here are steps that I followed in order to reproduce this issue in fresh WP installation:

- Created contact page in english language with ‘contact-us’ slug and ‘6156’ ID.
- Added it’s translation with ‘neem-contact-met-ons-op’ slug and ‘6158’ ID.
- Selected ‘Adjust IDs for multilingual functionality’ checkbox from WPML >> Languages > Make themes work multilingual.
- Then added following code in footer.php file:

<a href="<?php echo get_permalink(6156); ?>">Contact Page</a>

And it’s showing correct translated page link when I switch language as you can see in attached screenshots.

Thank you

The topic ‘[Closed] get_permalink doesn't return translated url’ is closed to new replies.