Skip to content

Instantly share code, notes, and snippets.

@EdenK
Last active October 11, 2018 16:30
Show Gist options
  • Save EdenK/61297b6c42279c487a8ba9ce5c64430f to your computer and use it in GitHub Desktop.
Save EdenK/61297b6c42279c487a8ba9ce5c64430f to your computer and use it in GitHub Desktop.
Wordpress: WPML & Elementor fix for elementor library translations (Header etc..).
<?php
/**
* Wordpress: WPML & Elementor fix for elementor library translations (Header etc..).
*/
function wpml_elementor_library( $theme_template_id ) {
return apply_filters( 'wpml_object_id', $theme_template_id, 'elementor_library', true );
}
add_filter('elementor/theme/get_location_templates/template_id', 'wpml_elementor_library', 10, 1);
/**
* Fix elementor library cahce that saved only the current langauge and overwrite all the others.
*/
function elementor_library_set_suppress_filters( $query ) {
if( $query->query_vars['post_type'] === 'elementor_library'
&& $query->query_vars['meta_key'] === '_elementor_conditions' ) {
$query->set( 'suppress_filters', true );
}
}
add_action( 'pre_get_posts', 'elementor_library_set_suppress_filters' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment