Hi I am using an exteral site which redirects to my wordpress site with some url parameters. Unfortunately one of these is m which is causing a conflict which wordpress's native parameters and throwing a 404 not found. is there any I can tell wordpress to ignore that parameter for a specific page?
-
It's better to not use the parameter on the external site.Nicolai Grossherr– Nicolai Grossherr2017-01-13 13:51:13 +00:00Commented Jan 13, 2017 at 13:51
-
Yes that would preferable, but it's not my site, so I need a workaround.frank astin– frank astin2017-01-13 13:59:35 +00:00Commented Jan 13, 2017 at 13:59
Add a comment
|
1 Answer
You can filter request and unset m there, which will remove it from the query. This is a simple example that will remove it in all cases, you probably want to narrow the check down with something else, like checking if pagename is also set:
function wpd_request_filter( $request ){
if( isset( $request['m'] ) ){
unset( $request['m'] );
}
return $request;
}
add_filter( 'request', 'wpd_request_filter' );
You can var_dump( $request ) in the filter to see what it contains for different types of requests.