Skip to content

Instantly share code, notes, and snippets.

@dgoze
Forked from carlodaniele/add-query-vars.php
Created May 6, 2020 15:28
Show Gist options
  • Save dgoze/e290bff984f4ef0b090294781a8c290f to your computer and use it in GitHub Desktop.
Save dgoze/e290bff984f4ef0b090294781a8c290f to your computer and use it in GitHub Desktop.
Register custom query vars
<?php
/**
* Register custom query vars
*
* @param array $vars The array of available query variables
*
* @link https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
*/
function myplugin_register_query_vars( $vars ) {
$vars[] = 'key1';
$vars[] = 'key2';
return $vars;
}
add_filter( 'query_vars', 'myplugin_register_query_vars' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment