How WordPress Knows What Page You’re On

This post about how WordPress works with URL from Ryan McCue has almost everything I love in such things:

  1. A certified expert.
  2. A thorough examination of both history and details.
  3. Disambiguations of things that can trip people up.
  4. A little more detail that I need to learn.

In short, it’s new best place to go if you’re interested in or working on the way that WordPress handles processing URLs for your website. Here’s the part that most stuck with me:

Extra permastructs are typically generated by core helpers like register_post_type() or register_taxonomy(). Plugins don’t typically add permastructs manually, as the generation makes a lot of assumptions about things you want.

Once all of this is done, WordPress saves the rules into the rewrite_rule option to avoid having to regenerate them on the next request. However, if a plugin has flushed the write rules before wp_loaded, this saving is deferred to wp_loaded to ensure plugins don’t break the whole system.

Now that we know we have rewrite rules (whether loaded from the option or generated fresh), we can finally get around to routing our requests.

Add a Comment

Your email address will not be published. Required fields are marked *