add_action('save_post', 'set_dictionary_terms'); function set_dictionary_terms($post_ID) { $title = get_the_title($post_ID); $first_letter = strtolower(substr($title, 0, 1)); if ( get_post_type($post_ID) == 'dictionary' ) { wp_set_object_terms( $post_ID, $first_letter, 'mydictionary' ); } } // Works perfectly for all standard letters excepting exotic ones like Ą, Ż, Ź etc. (I've already created terms for them, the slugs for them are like a-2, z-2, z-3 etc., tried something like if($first_letter == "ą") { $first_letter = "a-2" }; but doesn't work either, any ideas?