Title: WebAnim's Replies | WordPress.org

---

# WebAnim

  [  ](https://wordpress.org/support/users/webanim/)

 *   [Profile](https://wordpress.org/support/users/webanim/)
 *   [Topics Started](https://wordpress.org/support/users/webanim/topics/)
 *   [Replies Created](https://wordpress.org/support/users/webanim/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/webanim/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/webanim/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/webanim/engagements/)
 *   [Favorites](https://wordpress.org/support/users/webanim/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Polylang] v 1.0.2 doesn't display primary menu when searching](https://wordpress.org/support/topic/v-102-doesnt-display-primary-menu-when-searching/)
 *  [WebAnim](https://wordpress.org/support/users/webanim/)
 * (@webanim)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/v-102-doesnt-display-primary-menu-when-searching/#post-3512162)
 * 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']);
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Polylang] v 1.0.2 doesn't display primary menu when searching](https://wordpress.org/support/topic/v-102-doesnt-display-primary-menu-when-searching/)
 *  [WebAnim](https://wordpress.org/support/users/webanim/)
 * (@webanim)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/v-102-doesnt-display-primary-menu-when-searching/#post-3512156)
 * 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)