Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ulziibat-n/26739ae745017f841c4d03211f5962ad to your computer and use it in GitHub Desktop.
Save ulziibat-n/26739ae745017f841c4d03211f5962ad 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