I know that get_queried_object
contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this?
For instance:
query_posts
get_posts
get_post
new WP_Query
- etc.
I know that get_queried_object
contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this?
For instance:
query_posts
get_posts
get_post
new WP_Query
You must be logged in to post a comment.
As per its laconic source:
This function retrieves object from main query. As such it is affected by anything that changes main query. From your list that would be
query_posts()
(reason number umpteen it should not be used).All those query calls you mentioned are wrappers around
WP_Query
( except wp_query which is itself WP_Query, no wrappers necessary )So
get_queried_object
refers to the main query and calls$wp_query->get_queried_object();
Which we can find here:
http://core.trac.wordpress.org/browser/tags/3.5.1//wp-includes/query.php#L2987
So the arguments passed in and how many iterations of the loop you’ve gone through are the determining factors.
TDLR: Just followed the code, most IDEs have a jump to definition button that would take you directly there