Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You need to use PHP to check if the current page or a custom post type (CPT) post is translated into its secondary language. Depending on the translation status, you want to display different text messages.
Solution:
We recommend using the

wpml_element_has_translations

filter to determine if a post type or a taxonomy term has translations available. For implementing this, you can refer to the WPML Hooks Reference for detailed guidance on how to use this filter.
For more information, please visit the WPML element has translations and the WPML Hooks Reference.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.

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 0 voices.

Last updated by Andrey 1 week 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.