Skip to content

Instantly share code, notes, and snippets.

/mu-plugin2.php Secret

Created December 13, 2013 21:47
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 anonymous/2c13d98f1330c313550c to your computer and use it in GitHub Desktop.
Save anonymous/2c13d98f1330c313550c to your computer and use it in GitHub Desktop.
<?php
function wpse10691_redirect_canonical( $redirect_url, $requested_url ) {
global $wp_rewrite;
if( is_single() && in_category( 'intl' ) && strpos( $wp_rewrite->permalink_structure, '%category%' ) !== false && $cat = get_query_var( 'category_name' ) ) {
$category = get_category_by_path( $cat );
if( $category && !is_wp_error( $category ) ) {
return str_replace( 'intl', $cat, $redirect_url );
}
}
return $redirect_url;
}
add_filter( 'redirect_canonical', 'wpse10691_redirect_canonical', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment