On a multisite installation, which is running the Polylang plugin, I want to add a custom rewrite rule.
Currently, my permalink structure is:
http://host.com/sitename/language/pagename
Now I want to add a querystring called country, as such:
http://host.com/sitename/country/language/pagename
I have tried the following, but to no avail:
function custom_rewrite_basic() {
add_rewrite_tag('%country%', '([^&]+)');
add_rewrite_rule('^([a-z]+)/?', 'index.php?country=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');
Any thoughts?
-- EDIT
Getting closer, but still not there:
add_rewrite_tag('%country%', '([^&]+)');
add_rewrite_tag('%lang%', '([^&]+)');
add_rewrite_rule('^([^/]*)/([^/]*)/?','index.php?country=$matches[1]&lang=$matches[2]','top');
The problem here is that:
- polylang recognized the country as the language, even though the query var "lang" is set correctly
- WP thinks we are not on the home page anymore