1. add_action('save_post', 'set_dictionary_terms');
  2.  
  3. function set_dictionary_terms($post_ID) {
  4.     $title = get_the_title($post_ID);
  5.     $first_letter = strtolower(substr($title, 0, 1));
  6.    
  7.     if ( get_post_type($post_ID) == 'dictionary' ) {
  8.    
  9.          wp_set_object_terms( $post_ID, $first_letter, 'mydictionary' );
  10.     }
  11. }
  12.  
  13. // 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?