Created
January 10, 2022 12:14
-
-
Save mgussekloo/e390396cae57460c09c418d7334c6bc1 to your computer and use it in GitHub Desktop.
Prevent Permalink Manager to redirect the current URL to the current URL.
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
<?php | |
// exit if accessed directly | |
if ( ! defined( 'ABSPATH' ) ) exit; | |
add_filter('permalink_manager_filter_redirect', function($correct_permalink, $redirect_type, $queried_object) { | |
$relative = wp_make_link_relative($correct_permalink); | |
$old_uri = wp_make_link_relative($_SERVER['REQUEST_URI']); | |
if ($relative == $old_uri) { | |
return ''; | |
} | |
return $correct_permalink; | |
}, 10, 3); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment