Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulziibat-n/f6e8aec17e930409243a169899ba3fb5 to your computer and use it in GitHub Desktop.
Save ulziibat-n/f6e8aec17e930409243a169899ba3fb5 to your computer and use it in GitHub Desktop.
Elementor get polylang translation of template
<?php
/**
* Elementor get polylang translation of template
*/
add_filter( 'elementor/theme/get_location_templates/template_id', function( $post_id ) {
if(!is_admin()){
if ( function_exists( 'pll_get_post' ) ) {
$translation_post_id = pll_get_post( $post_id );
if ( null === $translation_post_id ) {
// the current language is not defined yet
return $post_id;
} elseif ( false === $translation_post_id ) {
//no translation yet
return $post_id;
} elseif ( $translation_post_id > 0 ) {
// return translated post id
return $translation_post_id;
}
}
}
return $post_id;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment