Using query_vars filter

The query vars filter is unnecessary for what you’re doing here, as you’re not using it in a query. Adding it to the URL as a GET parameter will not make it appear in the array of query vars, as there’s no mechanism that converts a GET var to a query var, you’ve only ensured it won’t be removed if it’s added to the query.

As long as the GET var is unique and not reserved by WordPress, there’s nothing that should prevent setting and then accessing a GET var via normal means: $_GET['my-preview'].

Leave a Comment