Skip to content

Instantly share code, notes, and snippets.

@mcaskill
Last active November 17, 2017 11:11
Show Gist options
  • Save mcaskill/3df63784daa66d4fd0f7 to your computer and use it in GitHub Desktop.
Save mcaskill/3df63784daa66d4fd0f7 to your computer and use it in GitHub Desktop.
WordPress : Determine if a query variable is set.
<?php
/**
* Check if the current variable is set, and is not NULL, in the WP_Query class.
*
* @see WP_Query::$query_vars
* @uses $wp_query
*
* @param string $var The variable key to be checked.
* @return bool True if the current variable is set.
*/
function has_query_var( $var ) {
global $wp_query;
return isset( $wp_query->query_vars[ $var ] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment