multilingual adding a category to the url
-
Hi all, I’m using this
function post_type_link($post_link, $id = 0 ){ $post = get_post($id); if(!$post instanceof WP_Post) return $post_link; $typenow = $post->post_type; if ( $post->post_type !== 'resources' ) return $post_link; $terms = get_the_terms($post->ID, 'resource_type'); if( is_wp_error($terms) || !$terms ) { $category = 'uncategorized'; } else { $category_obj = array_pop($terms); $category = $category_obj->slug; } $name = $post->post_name; return home_url(user_trailingslashit( "resources/$category/$name" )); } add_filter( 'post_type_link', 'post_type_link', 10 ); add_filter( 'post_link', 'post_type_link', 10 );
to add taxonomies to the urls of a custom post type. everything work as expected except when I view a post that was written in korean.
if I look at the “Permalink” that is under the ‘Title’ field on the edit page the $name is printed in i guess ASCII or unicode or something. it looks like:
%eb%b3%b4%ec%8a%a4
wondering if anyone has any insight on how to fix this so that it displays the characters instead. Or if anyone knows where in the source I can find the function that outputs that ‘permalink’ text. Thanks!
PS and FYI: removing this code causes the ‘permalink’ to display the characters correctly.
- The topic ‘multilingual adding a category to the url’ is closed to new replies.