Say, I have a WordPress installation running at example.com and have the following url
Now, I want WordPress to ignore the w=100 part because, every time I pass a numeric argument to w, WordPress redirects me to the single page, I assume this has something to do with Attachments.
I can’t rename w to anything else because it is out of my control, my site has to work with a third party application that will not let me alter this condition.
I tried this
JavaScript
x
add_filter('request', array($this,'on_request'));
function on_request($vars){
unset($vars['w']);
return $vars;
}
And it wouldn’t work – any advice on this please ?
Advertisement
Answer
Alright, I solved it myself.
JavaScript
add_filter( 'request', 'alter_the_query' );
function alter_the_query( $request ) {
unset($request['w']);
return $request;
}