Created
August 29, 2019 07:31
-
-
Save Inzman/64cae6541186fb7e6d17d06d7cf5da36 to your computer and use it in GitHub Desktop.
WPML get translations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global $sitepress; | |
| $trid = $sitepress->get_element_trid($post_id); | |
| if($trid){ | |
| $translations = $sitepress->get_element_translations($trid); | |
| // Unset current language | |
| unset($translations[ICL_LANGUAGE_CODE]); | |
| foreach($translations as $translation){ | |
| echo get_post_meta($translation->element_id, 'my_field', true); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment