When should add_rewrite_tag() be used?

Posted by Prem Tiwari | Updated on

The fundamental difference is:

  • The add_rewrite_rule() adds a particular rule which is interpreted
  • The add_rewrite_tag() adds a placeholder to use in url structures. This placeholder is then used to generate multiple rules.

For instance – suppose you’re a travel agent advertising hotels in various countries. You may want a hotel’s url to be like:

For example:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers