Created
March 2, 2017 16:41
-
-
Save ofernandolopes/48dc99bd122a589e3981a61c8ddd7d27 to your computer and use it in GitHub Desktop.
WordPress - Redirect a page using a filter
This file contains hidden or 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
//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