-
-
Save anonymous/2c13d98f1330c313550c to your computer and use it in GitHub Desktop.
This file contains 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
<?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