4

I am doing some deep modding of the rewrite system and custom post_types but before I can continue I must find out how WordPress handles the rewrites.

I found the function url_to_postid() but WordPress it self doesn't seam to use it to resolve permalinks into queries?

For example: If I hook into the pre_get_post functions, and browse a page or a custom post_type the provided query now include "is_page" or "attachment" etc but if i where to type a URL at random, this data will not show. Where does WordPress figure out if the URL is a page|posttype|attachment or not? And how can I hook into this?

2

If you have a look at the Action Reference, you'll see all of the actions executed before pre_get_posts. The two you'll probably want to investigate are parse_request and parse_query (yes, those are lacking in documentation).

The part you're probably most interested in is parse_request, where rewrite rules are matched against the requested URI. You can see it in source here.

When a front end request happens, the file wp-blog-header.php is loaded, which calls wp(), which calls the main() method of the WP class, which calls the parse_request() method. At the bottom of that function, you'll see where the parse_request action is executed.

EDIT

Also see this page in Codex for some more in-depth info: Query Overview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.