Why WP_Query::is_date() returns false when ‘date_query’ argument is set?

The values retrieved by the is_date(), is_day(), etc. methods are set inside the parse_query method and they really seem to be intended for the main query, whether that is explicitly stated (intended) or not. The code parses the public query variables to determine those settings.

My interpretation is that these values aren’t really meant for secondary queries, and really don’t make much sense for secondary queries either. You’ve just run the query, you know that it is a date/tax/whatever query. That part doesn’t need to be determined for you by parsing the query variables.

To did a bit deeper, I’d say the problem stems from WP_Query being a bit schizophrenic. It parsed the request to determine which page ought to load, rather than just being a tool to query the database for posts. It does two jobs, rather than one, which is poor design in my opinion. I think distinct code should parse the request and then pass arguments to WP_Query. Maybe that is just me.

Is it a bug? I’d call it that, at least “weird design”. If WP_Query is going to do both jobs, it should at least set the class variables consistently, or split the class into two each with a single purpose. Of course, I don’t get to canonically declare something a “bug” or not 🙂