Rewrite URL – how to do a SEO-friendly Unicode custom URL?

If you write your post titles in Bānglā but set the post slug in English, you can do this:

 function wpse117090_pre_post_link( $permalink, $post ) {
    return str_replace( '%posttitle%', sanitize_title( $post->post_title ), $permalink );
 }

 add_filter( 'pre_post_link', 'wpse117090_pre_post_link', 10, 2 );

Then change your permalink structure to, for example, /%postname%/%posttitle%/

(Please note that the above code doesn’t make %posttitle% an actual queryable rewrite tag, it’s just a simple string that gets replaced by the sanitized post title when the permalinks are created.)

Leave a Comment