Get WP_Query query after execution?

It it possible to get the configuration of a the latest called WP_Query? I need to use it for debugging.

For example, if i run something like:

$the_query = new WP_Query( $args );
...

Could i get the $args array later by doing something like $the_query-args(); or something?

Topic wp-parse-args wp-query query Wordpress

Category Web


Try the $query_vars property:

$the_query = new WP_Query( $args );

$query_arguments = $the_query->query_vars;

Which should return an associative array of query variables. To test:

var_dump( $query_arguments );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.