Add language in the URL and fancy URL
-
Hi,
I’m trying unsuccesfully to add a query var, the language, into my wordpress installation.
I installed a plugin (GTranslate) and modified it so it adds a var (lang=) to the URL.
The current example of URL is https://www.example.com/blog/about/?lang=en
I would like to change it to
https://www.example.com/blog/en/about/
For all pages and posts.
But I’m clueless, I’ve been trying many options.
Currently, I added the following code to my child’s theme function.php:add_filter('query_vars', 'add_query_lang_filter') ; function add_query_lang_filter($query_vars) { $query_vars[] = filter_input( INPUT_GET, 'lang', FILTER_SANITIZE_STRING ) ?: 'fr'; return $query_vars ; }; function custom_rewrite_tag() { add_rewrite_rule('^([^/]+)/([^/]+)', '?lang=$matches[1]', 'top'); } add_action( 'init', 'custom_rewrite_tag' );
But no result.
Anybody could help me?
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Add language in the URL and fancy URL’ is closed to new replies.