Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement