WPML, multi language and search engine
If you are using Wordpress and the WPML plugin to manage your web site in multi language, you have surely noticed that when a visitor uses the search engine, Wordpress displays the result list of the default language and not of the language currently used by the visitor…
To upgrade this feature, I’ve done a little patch… It’s a quick and dirty one but it works (you can easily optimise this by using a function to overload the default behavior of Wordpress instead of directly modifying the standard Wordpress files (and loosing your modification during the next upgrade…)
Update the file wp-includes/general-template.php for the function get_bloginfo like this :
case 'short_language':
$output = get_locale();
$short_language = explode("_", $output);
$output = $short_language[0];
break;
And the on your theme (e.g. iNove in wp-content/themes/inove/templates/header.php file) :
You just have to modify the form like this :
<form action="<?php bloginfo('home'); ?>/<?php bloginfo('short_language'); ?>/"
method="get">
Have fun with Wordpress and WPML !
ps : you can also modify the links to your title/home to avoid switching language when a user click on the logo
<h1 id="title">
<a href="<?php bloginfo('url'); ?>/<?php bloginfo('short_language'); ?>/">
<?php bloginfo('name'); ?>
</a>
</h1>
and for the breadcrumbs…
<a title="<?php _e('Home', 'inove'); ?>"
href="<?php echo get_settings('home'); ?>/<?php bloginfo('short_language'); ?>/">
<?php _e('Home', 'inove'); ?>
</a>
By the way, the idea comes from this thread…