Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to debug a problem with filters I have in place. they're affecting any url that includes a query; eg, http://my.domain.hk/?attachment=1. does anyone know in which function WP begins to work with this kind of url, one that includes a query?

cheers,
Gregory

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Any url that doesn't point to a file/directory that actually exists is redirected (by .htaccess) to the index.php in the root of your WordPress install.

index.php is what actually loads WordPress and its settings etc. It then calls the function wp();, which is responsible for initialising WordPress' actually handling of the request.

wp() is little more than a wrapper for the wp-class class. In particular, the main() method:

function main($query_args = '') {
    $this->init();
    $this->parse_request($query_args);
    $this->send_headers();
    $this->query_posts();
    $this->handle_404();
    $this->register_globals();
    do_action_ref_array('wp', array(&$this));
}

The parse_request() method turns the request (handling pretty permalinks, internal rewrites and extra arguments -i.e. interpreting ?attachment=1) into 'query_vars' (variables concerning the query). The query_posts() method then turns that into an actual WP_Query object (the globals $wp_the_query and $wp_query - which are initialised in wp-settings.php).

share|improve this answer
    
thank you for the detailed answer. the phrase 'internal rewrites' helped me. I found what I was looking for in redirect_canonical(). cheers. –  Gregory May 1 '12 at 13:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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