Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created December 16, 2015 18:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/856e900680330ee503ed to your computer and use it in GitHub Desktop.
Save strangerstudios/856e900680330ee503ed to your computer and use it in GitHub Desktop.
Remove title as a query var so we can use it in our forms
/*
Remove title as a query var so we can use it in our forms
Since WP 4.4, using a title parameter in a URL will invoke a post query by title.
We want to disable that so we can use title as a parameter in our forms/etc.
Add this code to your active theme's functions.php or a custom plugin.
*/
function remove_title_query_var( $qvars ) {
$qvars = array_unique($qvars);
if(($key = array_search('title', $qvars)) !== false) {
unset($qvars[$key]);
}
return $qvars;
}
add_filter( 'query_vars', 'remove_title_query_var' , 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment