Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Created June 14, 2019 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dparker1005/03745f92a94a768ce4bbef4c8c61a1b4 to your computer and use it in GitHub Desktop.
Save dparker1005/03745f92a94a768ce4bbef4c8c61a1b4 to your computer and use it in GitHub Desktop.
Prevents wp_redirect to redirect to a specified page.
<?php
/**
* Disable Redirection to Specific Page
*/
function my_wp_redirect($location) {
// TODO: Change '10' to the page id that should not be redirected to
$page_id = 10;
if($location == get_the_permalink( $page_id ) ) {
$location = false;
}
return $location;
}
add_filter('wp_redirect', 'my_wp_redirect');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment