difference between $wp_the_query and $wp_query? & getting the values properly [duplicate]
IT Nursery
May 19, 2022
0
i have seen $wp_query and $wp_the_query in many plugins and themes. for me these two are just same thing with no difference. i am not looking to either use or get the values from $GLOBALS.
what is the actual difference between these two objects and when to use them?
What is the proper action /filter hook for getting and reading values from $wp_query and $wp_the_query.
1 Answer 1
You should read in this answer it explains it in depth.
in short,
$wp_query is the variable that holds a copy of $wp_the_query global query that could/can be modified by plugins and themes
$wp_the_query is the variable that holds an unmodified copy of the global query object and used to reset the $wp_query object when we call wp_reset_query()
I think you now understand as to why it makes sense to have both available to us.