I'm trying to add a local variable to my URL.
As an example I have this URL:
mysite.com/my-page-name/
And I want to add 'en' variable into it and leave the page working properly:
mysite.com/en/my-page-name/
I tried to deal with it using add_rewrite_tag()
and add_rewrite_rule()
but it isn't working so what am I doing wrong?
add_rewrite_tag('%locale%', '^([a-z]{2})');
add_rewrite_rule('^([a-z]{2})/(.+)[/$]', 'index.php?pagename=$matches[2]', 'top');