Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. function tag_to_category ($post_id = 0) {
  2. if (!$post_id) return;
  3. $post_tags = get_the_tags($post_id);
  4. foreach ($post_tags as $tag) {
  5. $cat_id = wp_create_category($tag->name);
  6. $result = wp_set_post_terms( $post_id, $cat_id, 'category', true );
  7. }
  8. }
  9.  
  10. add_action('save_post','tag_to_category');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement