Advertisement
Guest User

Untitled

a guest
Oct 10th, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  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?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement