Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

Over the past three years, I have almost stopped buying new plugins. In fact, the palette of tools I actually use in real projects has only been getting smaller. Even with hundreds of plugins and dozens of bundles available, only a very small number of them make it into constant use. Thinking about it, I…

In order to be able to add and work with your own custom query vars that you append to URLs (eg: “http://mysite.com/some_page/?my_var=foo” – for example using add_query_arg()) you need to add them to the public query variables available to WP_Query. These are built up when WP_Query instantiates, but fortunately are passed through a filter ‘query_vars‘ before they are actually used to populate the $query_vars property of WP_Query.
So, to expose your new, custom query variable to WP_Query hook into the ‘query_vars‘ filter, add your query variable to the $vars array that is passed by the filter, and remember to return the array as the output of your filter function. See below:

Subscribe
Get exclusive studio offers and benefits