Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Created September 17, 2018 12:44
Show Gist options
  • Save nicomollet/a7283d8c3a2707f7be04f3f507437e71 to your computer and use it in GitHub Desktop.
Save nicomollet/a7283d8c3a2707f7be04f3f507437e71 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