As stated in one of the answers in this question and in the codex entry for the request
filter, said filter gets called only in a default query, such as the main query used for a loop. My question is, what else is or isn't considered a default query? Would creating a new WP_Query
object be considered such?
2 Answers
The "default" query is the one WordPress does itself, based on the URL and such, automatically.
Any query you create manually, via a new WP_Query or by calling query_posts(), will not use the 'request' filter.
There is only one "default" query, and you cannot trigger it via any code in the template.
-
Just needed some clarification. Thanks for the answer, Otto man. Feb 15, 2012 at 1:34
request
is only applied once, by parse_request()
, a method of the WP
class. There is only one reference to this, it is by another method of WP
, main()
. main()
is referenced one time, by wp()
. wp()
is referenced in a few different contexts by a number of different functions and files: wp_trackback.php
, get_feed()
, wp-blog-header.php
, wp_edit_posts_query()
, and wp_edit_attachments_query()
. So, looking through that, nothing that `WP_Query calls is listed.
Short answer: I'd say no, it does not call request
.
All that said, my work is based on working backwards with phpxref (hence the links), so I may have missed something, or it may have missed something. A better way to ask your question might be to ask on what you're trying to do, not on your implementation of it.
Just a note: main()
does call query_posts()
, which (I think) does the default query and such, but an instance of WP_Query alone shouldn't be enough to trigger this from what I've seen.