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:
- A certified expert.
- A thorough examination of both history and details.
- Disambiguations of things that can trip people up.
- 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_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_ruleoption 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_loadedto 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.