Skip to content

Instantly share code, notes, and snippets.

@ofernandolopes
Created March 2, 2017 16:41
Show Gist options
  • Save ofernandolopes/48dc99bd122a589e3981a61c8ddd7d27 to your computer and use it in GitHub Desktop.
Save ofernandolopes/48dc99bd122a589e3981a61c8ddd7d27 to your computer and use it in GitHub Desktop.
WordPress - Redirect a page using a filter
//Redirect a page using a filter
add_filter('get_the_permalink','my_permalink_redirect');
function my_permalink_redirect($permalink) {
global $post;
if ($post->ID == your_post_id_here) { //Page ID you want to redirect
$permalink = 'http://new-url.com/pagename'; //Redirect destination page
}
return $permalink;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment