On a multisite set up, which is working the Polylang plugin, I need to add a customized rewrite rule.
Presently, my permalink construction is:
http://host.com/sitename/language/pagename
Now I need to add a querystring known as nation, as such:
http://host.com/sitename/nation/language/pagename
I’ve tried the next, however to no avail:
perform custom_rewrite_basic() {
add_rewrite_tag('%nation%', '([^&]+)');
add_rewrite_rule('^([a-z]+)/?', 'index.php?nation=$matches[1]', 'prime');
}
add_action('init', 'custom_rewrite_basic');
Any ideas?
— EDIT
Getting nearer, however nonetheless not there:
add_rewrite_tag('%nation%', '([^&]+)');
add_rewrite_tag('%lang%', '([^&]+)');
add_rewrite_rule('^([^/]*)/([^/]*)/?','index.php?nation=$matches[1]&lang=$matches[2]','prime');
The issue right here is that:
- polylang acknowledged the nation because the language, regardless that the question var “lang” is about appropriately
- WP thinks we aren’t on the house web page anymore