I'm using the WPML Wordpress plugin to translate my website. My default language is French. When I'm in a translated page, the home_url()
is rewrite with the current language. How can I disable this rewrite so my home_url()
always redirect to the french homepage?
Translate page url : http://www.mydomain.com/en/test/
Actual home_url()
: http://www.mydomain.com/en/
Desired home_url()
: http://www.mydomain.com/
I've already tried these solutions :
http://wpml.org/forums/topic/wpml-overwrites-home_url-to-append-language-suffix/ http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/home-page-link/ http://wpml.org/forums/topic/wpml-changed-my-default-home-url/
Sorry for my poor english and thanks for the help! Let me know if I need to provide any other information.
I guess you could override what's being done by WPML and override home_url() the same way it does by using the hook/filter "home_url" and get the url without the lang by using $_SERVER['SERVER_NAME']; or some other way.
Maybe something like this could work :
add_filter( 'home_url', 'fix_home_url_lang', 100, 4 );
function fix_home_url_lang( $url, $path, $orig_scheme, $blog_id ) {
return 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . $path;
}
This doesn't take into account any multisite you could have, so be careful. Also, maybe you should use the parameters passed to the function to figure out the url you want.