Skip to content

Instantly share code, notes, and snippets.

@Inzman
Created August 29, 2019 07:31
Show Gist options
  • Select an option

  • Save Inzman/64cae6541186fb7e6d17d06d7cf5da36 to your computer and use it in GitHub Desktop.

Select an option

Save Inzman/64cae6541186fb7e6d17d06d7cf5da36 to your computer and use it in GitHub Desktop.
WPML get translations
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