Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry i made a mistake in the 1st reply, the ‘pre_get_posts’ hook is an action, not a filter, so the better temporary fix is:

    add_action( 'pre_get_posts', 'pll102_menu_repair' );
    function pll102_menu_repair( $query ) {
    	if(isset($query->query_vars['lang']) && is_search() && !$query->is_search) unset($query->query_vars['lang']);
    }

    It’s a bug in v1.0.2 (v0.9.8 is ok, nav menus won’t disappear after search).

    I can reproduce this bug without other plugins, with Twenty eleven theme and WP v3.5.1.

    I found a (temporary) solution (add this to your theme’s functions.php):

    add_filter( 'pre_get_posts', 'pll102_menu_repair' );
    function pll102_menu_repair( $query ) {
    	if(isset($query->query_vars['lang']) && is_search() && !$query->is_search) unset($query->query_vars['lang']);
    	return $query;
    }

    I think this is the root of the bug:
    (Polylang v1.0.2 – include/core.php – Polylang_Core::pre_get_posts() ):

    // sets the language in case we hide the default language
    	if ($this->options['hide_default'] && !isset($qv['lang']) && ($is_archive || is_search() || (count($query->query) == 1 && !empty($qv['feed'])) ))
    		$query->set('lang', $this->options['default_lang']);

    It would be better ( is_search() -> $q->is_search ):

    if ($this->options['hide_default'] && !isset($qv['lang']) && ($is_archive || $q->is_search || (count($query->query) == 1 && !empty($qv['feed'])) ))
    		$query->set('lang', $this->options['default_lang']);

    But don’t forget: it’s a great plugin from a great developer!

Viewing 2 replies - 1 through 2 (of 2 total)