Polyglot search fix

While implementing the Polyglot plugin on a WordPress site I was working on, I found a bug related to the search form: the plugin appends “/lang-pref/en/” (or whatever other ISO language code) to the search string (in the URL - when using “pretty permalinks” AKA URL rewriting).

This does not directly affect the first search, but the search field is then filled with “my search string/lang-pref/en”, which is confusing for the visitor.

A quick solution is to filter the search query and remove the said string:

/* Clean the search URL */
function polyglot_clean_search_URL () {
return preg_replace('@/lang-pref/[a-z]{2}/@i','',get_search_query());
}
add_filter('the_search_query', 'polyglot_clean_search_URL', 1);

You can either add this code to your theme’s functions.php, or to the plugin’s file, at the end.

Article Info

This article was read 3494 times.

All scripts on this site are free. However, if you feel you want to contribute, use the button below.

COMMENTS (No comments)

There are no comments for this post so far.

Post a comment

Articles in the category

Tutorial for an AJAX login using MOOdalBox

While browsing the e-magine forums, answering a topic here and there, I discovered very well written and simple to follow tutorial on bulding a modal login dialogue using MOOdalBox. I’m really happy to see such a piece of work – it makes the time I spent writing the scripts even more meaningful. Thank you, Jani [...]

he said.. she said.. forums !

I finally decided to extend the e-magine.ro community (yeah, I’m referring to you.. 5-6 guys.. ) with a forum. Without further ado, I introduce the e-magine.ro forums The place where you can ask and get answers from other users of my scripts if I’m somehow unavailable. The place where you’ll find other’s solutions, publicly addressed, [...]