where is permalink info stored in database?

I see that I can edit permalink information in wp-admin page > settings > permalinks. However, where is that information actually stored in the database?

Related posts

Leave a Reply

3 comments

  1. In the wp_options table there is a record where option_name = "permalink_structure".

    However, the true, ultimate control of url rewriting is controlled by the WP_Rewrite API which saves/caches its information in the rewrite_rules wordpress option (also found in the wp_options table).

    EDIT:

    Also, when editing a page/post, you can change the “permalink” for that page/post (right below where you change the title). All that is doing is merely setting the post_name field for that page’s/post’s entry in wp_posts table (aka it’s changing the “slug” for that page).

    For all pages, it seems that the default rewrite rules are the following:

    [(.?.+?)/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2]
    [(.?.+?)/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2]
    [(.?.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]
    

    That list was obtained by me running this php code: echo nl2br('rules = '.print_r( $wp_rewrite->rules, true) . "n");

    There does not seem to be any builtin way to edit routing for pages since the permalink structure only applies to posts.

    EDIT:

    More random information I’m discovering: if your permalink_structure is an empty string (which is the “default” option you can choose), then wordpress completely skips all rewriting — I’m really not sure why that’s the case, but it is.

  2. The actual information – e.g. the ‘slug’ for the page or post is stored in wp_posts under the post_name column. This is a slugified version of post_title normally, but can be overwritten on a page by page basis.

    The full permalink is deconstructed based on what settings you have chosen in Settings -> Permalinks, but the actual slug is in post_name in wp_posts.

  3. Permalink information is stored in wp_options.

    Table name :- $wpdb->prefix’options’

    And search option name like ‘permalink_structure’ in option table.

    In that row in a table u can view the permalink structure.