Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Last active September 10, 2019 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicomollet/b603b29baef67eb90877d4f8358a98e1 to your computer and use it in GitHub Desktop.
Save nicomollet/b603b29baef67eb90877d4f8358a98e1 to your computer and use it in GitHub Desktop.
Fix for Elementor template conditions not compatible with polylang (you need to save again one of your templates to make it work, after putting this function in your plugin/theme). Needs to be priority 1
<?php
/**
* Fix for Elementor template conditions not compatible with Polylang (you need to save again one of your templates to make it work, after putting this function in your plugin/theme)
* Needs to be priority 1, since Polylang uses the action parse_query which is fired before pre_get_posts
*
* @link https://github.com/polylang/polylang/issues/152#issuecomment-320602328
*
* @param WP_Query $query
*/
function polylang_elementor_library_conditions_parse_query( $query ) {
if ( is_admin() && ! empty( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] === 'elementor_library'
&& ! empty( $query->query_vars['meta_key'] )
&& $query->query_vars['meta_key'] === '_elementor_conditions' ) {
$query->set( 'lang', '' );
}
}
add_action( 'parse_query', 'polylang_elementor_library_conditions_parse_query', 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment