Created
December 16, 2015 18:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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