Skip to content

Instantly share code, notes, and snippets.

@drrobotnik
Last active August 26, 2015 17:20
Show Gist options
  • Save drrobotnik/f57c0c71af97092265ac to your computer and use it in GitHub Desktop.
Save drrobotnik/f57c0c71af97092265ac to your computer and use it in GitHub Desktop.
canon redirect
/*
* Request is to set up 301 redirects for permalink change.
* permalink changing from:
* http://vip.local/blog/2015/06/27/hello-world/
* to:
* http://vip.local/blog/uncategorized/hello-world-1/
*/
// Successfully applies new url structure
wpcom_vip_load_permastruct( '/%category%/%postname%-%post_id%/' );
/*
* Does not appear to ever fire unless you access the direct url ( http://vip.local/blog/?p=1 )
* We'd like the old url (http://vip.local/blog/2015/06/27/hello-world/) to redirect to the new one.
*/
add_filter( 'redirect_canonical', 'tt_redirect_canonical', 10, 2 );
function tt_redirect_canonical( $redirect_url, $requested_url ) {
/* Never fires if someone accesses the old urls. */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment