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.

This topic contains 1 reply, has 2 voices.

Last updated by Dražen 1 year, 5 months ago.

Author Posts
August 31, 2023 at 4:12 pm #14322441

tobiasW-41

I am accessing my Website via wpdb from a php script on the server. My default language is German. I have the ID of a german post. How do I fetch the post URL of the associated english translation using wpdb? Thanks!

September 1, 2023 at 6:22 am #14324353

Dražen
Supporter

Languages: English (English )

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

Hello,

there are different approaches you can use the get translated URLs, for example you can use WPML_permalink and using default language permalink get translated one:

Example:

// will return <em><u>hidden link</u></em>
$wpml_permalink = apply_filters( 'wpml_permalink', '<em><u>hidden link</u></em>', 'de' );

Please check the next hooks:

- https://wpml.org/wpml-hook/wpml_get_element_translations/
- https://wpml.org/wpml-hook/wpml_object_id/
- https://wpml.org/wpml-hook/wpml_element_link/
- https://wpml.org/wpml-hook/wpml_permalink/
- https://wpml.org/wpml-hook/wpml_get_translated_slug/

Regards,
Drazen

The topic ‘[Closed] Fetch post URL using wpdb’ is closed to new replies.