The goal is to have this working:
www.pageurl.de -> nothing happens
www.pageurl.de/en/ -> a variable is set and stored in a cookie
this also need to work with permalinks, categories etc. like this:
i tried to work with
but the endpoint (that makes sense) only works at the end of the url
i also tried to work with
add_rewrite_rule('^' . $language . '/([^/]*)/?$', 'index.php?lang=$matches', 'top');
but www.pageurl.de/en/ only returns a 404
What is the best way to do this?
I need to have the language pattern in the url on the whole page, lets say after changing the page in a menu the "en" has to be in the url.