0

The Codex doesn't really explain it very well, what is it used for and how do I use it exactly?

1

It is explained pretty thoroughly in the Codex, in my opinion. It serves a purpose e.g. when you want to grab posts for your taxonomy, it is a URL slug for your taxonomy, e.g. example.com/tag/cats -> example.com/query_var/cats.

Note: The query_var is used for direct queries through WP_Query like

new WP_Query( array( 'people' => $person_name ) )

and URL queries like /?people=$person_name. Setting query_var to false will disable these methods, but you can still fetch posts with an explicit WP_Query taxonomy query like

WP_Query(array('taxonomy'=>'people', 'term'=>$person_name)).

Basically, query_var is part of the WordPress Query Vars.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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