passing an Args
instance to WP_Query
without toArray()
silently yields subtle bugs
#40
Milestone
Args
instance to WP_Query
without toArray()
silently yields subtle bugs
#40
I spent the past few hours trying to figure out why two nearly-identical queries in my project yielded wildly different results. Both used the same
tax_query->clauses
, but only one of the resulting queries actually respected the clause. It turns out that I had forgotten to calltoArray()
on the instance of\Args\WP_Query
prior to passing it to the\WP_Query
constructor. I would have expected that to cause an obvious error.The query with
new WP_Query($args->toArray())
correctly filtered posts bytax_query
, while the query withnew WP_Query($args)
did not respecttax_query
but also did not fail entirely.The text was updated successfully, but these errors were encountered: