My problem here is that
get_query_var('language')
isn’t defined in the functionset_my_locale
Because get_locale
(which applies the filter locale
) is called before wp()
(which parses the query & sets up the variables).
You’ll have to manually inspect the request yourself:
if ( strpos( $_SERVER['REQUEST_URI'], '/de/' ) === 0 ) {
// German
} else {
// English
}
Note this expects WordPress to be running under the root URL i.e. http://example.com/
Related Posts:
- How to change ?lang=cn into /cn/
- How make a multi language routes, with rewrite rules or rewrite endpoints?
- Use custom template on certain URLs
- Translate custom post type and taxonomy slug in URL?
- WPML language switcher for custom rewrite rules
- What’s the best approach to do this?
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- How to retrieve $_GET variables from rewritten URLs?
- Dynamic Endpoints
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- WordPress URLs without posts
- Need help with rewrite_rules_array
- Hijacking the URL for filtering
- Sub domain redirection to taxonomy
- custom htaccess rewrite rule for page
- Change URL for Blog?
- Sorting archive pages with “pretty” URLs?
- add_rewrite_rule again
- How to change page URLs to “www.site.com/page” instead of “example.com/blog/page” but keep post URLs as “example.com/blog/post”?
- Add_query_arg + two times the same argument?
- Redirecting all old links from previous EE site to new WP site in one go?
- Two “.htaccess” Files Located in Different Directories?
- Add .html extension to only one page in my WordPress site
- How to get “extended” path info from URL in a plugin
- Custom URL routing based on cookie value
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- How to perform a query at the URL?
- url rewriting for most recent post
- Is there a way to create alias without using htacess, permalinks or delving into code?
- hard flush_rewrite_rules() not regenerating .htaccess
- Remove Query String from URL on Redirect – Redirection Plugin
- Cleanup URL for a custom page in wordpress
- Rewrite Rules Are Redirecting and Not Passing VARs
- WordPress rewrite rules don’t need ^?
- custom template rewrite
- add_rewrite_rule fro html to another url not working
- Adding rewrite rules directly to .htaccess file
- WordPress redirects non-existing url to existing ones – how to disable
- How to rewrite url wordpress?
- WordPress Redirecting Non Category Pages /page/nnn to their Canonical URLs
- How to create a profile page for specfic / custom user role members?
- Can I change default registration link (without htaccess)?
- WPML – how to get the permalinks to display also the default language
- I want to add a new tag to WordPress URL permastruct
- How to remove trailing slash from root WordPress folder?
- Rewriting the URL of a custom post to a certain page
- QSA Rewrite Rule
- rewrite wordpress page url for seo friendly query strings
- Persist url parameter passed by a referrer website? [duplicate]
- Fixing custom rewrite rule
- htaccess rewrite ignored
- Best way to trigger rewrite rules
- Trouble with question mark in rewrite rule
- Redirect htaccess [closed]
- virtual page using url parameters to solve facebook sharing issues
- Why when I enter bad url wordpress doesn’t return error 404
- How would I get WordPress to parse /mypage/area/value as /mypage/?area=value?
- What URL rewriting rule should I write to retrieve a var in the URL?
- Weird characters behind every single link and images
- How to mask url of a specific page without affecting seo [closed]
- Mobile version and URL Rewrite
- Adding Theme File for Non-WordPress Content
- Show index.php template instead of 404 page template
- URL rewriting in wordpress using parameters
- Rewrite rules – page does not exist
- WordPress rewrite front page url
- URL structure for dynamic content broken since upgrade to 5.8
- Have unique URLs on the ad site
- Redirect users with “.” (dot) in their username and replace with “-” (dash) to correct profile
- WordPress dynamic page handle in theme
- Rewrite htacess rule doesn’t work
- I have a problem with WP_Rewrite
- URL of Website Changed by itself
- How to create dynamic URLs on WordPress?
- ../../page-name backend links are not rewritten
- 404 Rest Route not found – when serving behind “proxy”
- Rewrite Rules are Redirecting
- Prefix only some posts with a custom prefix
- Param causing 404
- How to use a capture from a rewrite rule inside a php file (like single.php)?
- url rewriting on custom post type
- Rewriting URL with 3 custom meta fields to add onto Pages
- Rewrite URL for Search + Special Characters / Umlaute
- rename author base from author url in wordpress not working
- Dynamic content and rewrite URLs
- Rewriting / Redirecting request outside wordpress
- Finding and removing unnecessary redirects
- Remove Page Slug from URL
- Needed to change slug to access page
- How to create short urls for sharing and downloadable content?
- URLs unchanged after migration
- Rewrite rule is not working
- How to stop WordPress creating URLs that don’t exist
- mysite.co.uk/wordpress redirects to mysite.co.uk?
- Post Type Rewrite Custom
- List posts with same tag?
- Changes done to .htaccess are not getting reverted back
- Help with url rewrite
- how to rewrite folder name in url to another name