This is just a little snippet that allow us to update post category programmatically, sure it’s a bit easy to update post category via PHPMyAdmin, MySQL Console and the easiest one is in the WordPress Dashboard but in some cases like by creating plugin or custom code we’d like to do it programmatically, so here you go, hope you’ll find this useful.
// all parameters are required
< ?php wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); ?>
You can find out more here http://codex.wordpress.org/Function_Reference/wp_set_object_terms
That’s it, Happy coding ^_^