3

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.

Anwer AR
  • 1,007
  • 11
  • 19

1 Answers1

9

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.

bynicolas
  • 2,289
  • 1
  • 10
  • 19