Skip to content

Instantly share code, notes, and snippets.

@mgussekloo
Created January 10, 2022 12:14
Show Gist options
  • Save mgussekloo/e390396cae57460c09c418d7334c6bc1 to your computer and use it in GitHub Desktop.
Save mgussekloo/e390396cae57460c09c418d7334c6bc1 to your computer and use it in GitHub Desktop.
Prevent Permalink Manager to redirect the current URL to the current URL.
<?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