Do WordPress Permalinks Refer to a Lookup Table in the Database?

I’m trying to figure out how to rewrite URLs while dropping the original parameter (whether it’s a number or text); basically exactly what WP does with it’s clean permalinks

Does a database lookup table exist that matches the post ID# to the permalink string as set in the post editor?

Related posts

2 comments

    1. You have a set of url patterns and matches (wp generate a number of url patters to satisfy user agents).
    2. once you request lets say domain.com/posts/2003/somestuff url, wp tring to find a pattern that match this url inside a rewrite_rules (array that stored in options table by option name rewrite_rules)
    3. once it found… its parsed to query or better to say – matched_rule
    4. matched rule basicly looks like dirty url (a url of wp site without turned on permalinks) , and matched_rule is a set of arguments that passed to WP_Query.
    5. Once WP_Query get arguments and return some data (posts/pages/etc…) all of this data (wp_query and results) passed to view (template), index.php/single.php/etc.php
    6. And here you got a page.

    This is human explanation without (almost without) any tech details. Hope its undestandable for everyone who didn’t work with rewrite_rules

  1. No, for the most part.

    WordPress stores its rewrite rules in the database. These are pattern-based rules for mapping URLs onto query parameters, and are determined by the permalink structure you’ve chosen (e.g. %post_name%) and any additional structures plugins have provided.

    For single items, WordPress extracts either %post_id% or %post_name% (slug) from the URL and fetches that post from the posts table.

Comments are closed.