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 2 replies, has 2 voices.
Last updated by George Botsev 1 year ago.
Author | Posts |
---|---|
February 8, 2024 at 10:50 am #15280629 | |
Hector Carneiro |
Hi I wonder if it exists a "official" way to know if if WMPL is active. Something like is_wpml_active() I'm developing a script that given a post ID would return an array with all ID from its translations. We develop plugins and themes and many customer request to be compatible with WPML Regards |
February 8, 2024 at 1:53 pm #15281644 | |
George Botsev Supporter
Languages: English (English ) Timezone: Europe/Sofia (GMT+02:00) |
Hello! if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { echo ("WPML is enabled"); } Or you can try: https://wpml.org/wpml-hook/wpml_default_language/ and use our hook there - if WPML is not active, it will return NULL |
February 8, 2024 at 1:59 pm #15281650 | |
George Botsev Supporter
Languages: English (English ) Timezone: Europe/Sofia (GMT+02:00) |
To get the translation of a certain element, you can use: https://wpml.org/wpml-hook/wpml_get_element_translations/ Do note that it requires trid - which can be obtained by: https://wpml.org/wpml-hook/wpml_element_trid/ So you can have: $post_id = 2; // Here is your ID $post_type = get_post_type($post_id); // Get the post type // Get "trid" of the post $trid = apply_filters( 'wpml_element_trid', NULL, $post_id, 'post_' . $post_type ); // Get the translations $translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'post_' . $post_type); var_dump($translations); |
The topic ‘[Closed] Check if WPML is active’ is closed to new replies.