This is a follow up from the question

How to attach region identifier to a pretty url?

I want to apply this add_rewrite_url to multiple pages?

I tried adding a 2nd add_rewrite_rule as follows:

add_action('init', 'country_selection_url');
function country_selection_url() {


function country_selection($query_vars){
    return $query_vars;

Is it becasue I removed the ? at the end of the first parameter in the add_rewrite_rule? (IE: '^teacher/([^/]*)/' vs '^teacher/([^/]*)/?'

IF so why is the ? so darn important?

Secondly using regular expressions is there a way that this add_rewrite_rule could be applied to all pages?


The second part will be at most 2 characters long, but might not also be included.

  • 1
    Have you read add_rewrite_rule docs?
    – user47133
    Jan 17, 2017 at 15:30
  • I did the wordpress ones are pretty lacking.
    – mcv
    Jan 17, 2017 at 15:33
  • Ok, seeing that you read it: Do you know what the first parameter is?
    – user47133
    Jan 17, 2017 at 15:39
  • 1
    Yes that is the url, I want the world to see, it's the pretty url i want to use. I'm not a wordpress expert, but I have been doing php dev for quite sometime. I just am picking up on wordpress.
    – mcv
    Jan 17, 2017 at 15:41

1 Answer 1


Look at the rewrite_rules option in the wordpress database's option table. I bet your answer is end point.

  • I read that document, and I found it very vague, and not really helpful.
    – mcv
    Jan 17, 2017 at 16:36
  • End point is wordpress's power tool. Get your own way then. Jan 17, 2017 at 16:37
  • See that's not helpful either...
    – mcv
    Jan 17, 2017 at 16:38
  • I don't mind if anyone don't understand the use. Jan 17, 2017 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.