Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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