I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the site using the language switcher.
If url contains lang=de, then redirect to example/de/ If url contains lang=es, then redirect to example/es/
I've tried using the Redirection plugin by John Godley but I'm not sure how to set it up.
What's the best way to get this done?
I want to redirect my site to the correct url based on parameter. The url is passed when changing the language of the site using the language switcher.
If url contains lang=de, then redirect to example/de/ If url contains lang=es, then redirect to example/es/
I've tried using the Redirection plugin by John Godley but I'm not sure how to set it up.
What's the best way to get this done?
Share Improve this question asked Jan 27, 2020 at 11:45 Marco VMarco V 1131 silver badge6 bronze badges 2- Which plugin you have used – Ankush Kumar Commented Jan 27, 2020 at 11:49
- Redirection plugin by John Godley – Marco V Commented Jan 27, 2020 at 11:53
1 Answer
Reset to default 3You can use wp_redirect
with something like...
add_action( 'init', 'my_redirect');
function my_redirect() {
if (get_query_var('lang') == "de") {
wp_redirect( site_url('/de/') );
exit;
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744800880a4594481.html
评论列表(0条)