Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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 );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.