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.

Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Kyiv (GMT+02:00)

This topic contains 1 reply, has 0 voices.

Last updated by Andrey 3 days, 23 hours ago.

Assisted by: Andrey.

Author Posts
March 21, 2025 at 10:00 pm #16846520

paulM-12

Background of the issue:
I am doing some custom coding and would like to know if we can use PHP to check if the current page or a current CPT post is translated to its secondary language. Say if I am on the About page, and this page isn't translated, it should display a text message. If a page or a CPT post is translated, it should show a different text message.

Symptoms:
I've tried looking online, but no luck.

Questions:
Can I use PHP to check if the current page or CPT post is translated to its secondary language?
How can I display a text message based on whether a page or CPT post is translated?

March 21, 2025 at 10:18 pm #16846533

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for contacting WPML support.

You can use the filter wpml_element_has_translations to determine if a post type or a taxonomy term has translations available.

For more information, please visit: https://wpml.org/wpml-hook/wpml_element_has_translations/.

You can also refer to the WPML Hooks Reference here: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/.

I hope this helps.