Forked from nicomollet/polylang-elementor-conditions-compatibility.php
Created
September 10, 2019 14:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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