2011
05.12

Many user noticed, that since WordPress 3.0 it’s possible to do a search like domain.com/search/foobar and not just domain.com?s=foobar, but since 3.0.5 things started to work improperly.
The root of the problem is, that search term is not urldecoded. If you use WordPress in english, you won’t notice anything, unless you are searching for multiple words. But for us, who use it, with accents, it makes our lives a disaster.

So, I’ve created a small plugin, that will solve this issue.
I recommend you to use this as is, and not try to hack it into a theme’s functions.php, thus it will stop working correctly, because this plugin relies on a very low level hook in the WordPress core, which will run far before a theme’s functions.php included.

So, here is this tiny plugin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
/*
Plugin Name: Search fix
Description: Search fix
Author: DjZoNe
Version: 1.0
Author URI: http://djzone.im/
*/

function fix_search_query($query)
{
    if(!empty($query['s'])) $query['s']=urldecode($query['s']);

    return $query;
}

add_filter( 'request', 'fix_search_query' );

2 comments so far

Add Your Comment
  1. tnx :)
    works like a charm

  2. Great !
    u made my day
    thx