Prevent redirect to page/page when reserved term ‘name’ in $_POST when value is a page/post title

I would actually suggest an alternative approach – remove the function that causes the redirect in the first place:

function wpse_227033_disable_name_redirect() {
    if ( is_404() && isset( $_GET['name'], $_GET['instID'] ) )
        remove_action( 'template_redirect', 'redirect_canonical' );
}

add_action( 'wp', 'wpse_227033_disable_name_redirect' );

I’ve used the wp hook which runs pretty much just before template_redirect. Remember you’ll need to clear your browser cache before testing (those redirects are 301‘s).

Leave a Comment