Add the following code
In your main hooks file (maybe in functions.php)
add_action('init', 'my_custom_rewrite_rules');
Then add this function
function my_custom_rewrite_rules() {
// The rule
// Input: archives/publications/countries/kenya
// Output: archive-template.php?posttype=publications&taxo=countries&slug=kenya
add_rewrite_rule('archives/publications/countries/([^/]+)/', 'archive-template.php?posttype=publications&taxo=countries&slug=$matches[1]', 'top');
// Flush the rules (to activate them)
flush_rewrite_rules();
}
To learn more about regex and rewrite rules, those links might help
- https://regexone.com/
- http://wordpress.stackexchange.com/questions/5413/need-help-with-add-rewrite-rule
- http://wordpress.stackexchange.com/questions/3537/need-help-with-friendly-urls-in-wordpress
- https://www.youtube.com/watch?v=cd-jy85LQtU
And to test your rewrite rules, you can use any plugin you like, but I love this one: Monkeyman Rewrite Analyzer
NOTE Sorry I did not write the rule for you, I really have something that came up and do not have time to write the rule and test it, however, I hope the resources that I provided would help you. Good luck.
NOTE 2 Updated the rule. It is not tested. But this should give you a good start.