Hey @korporaalmedia,
Thank you for sharing!
To remove the default category when a post is already assigned to a category, please use this code snippet in the wp-config.php file:
//remove default category (uncategorized) when another category has been set
function remove_default_category($ID, $post) {
//get all categories for the post
$categories = wp_get_object_terms($ID, 'category');
//if there is more than one category set, check to see if one of them is the default
if (count($categories) > 1) {
foreach ($categories as $key => $category) {
//if category is the default, then remove it
if ($category->name == "Uncategorized") {
wp_remove_object_terms($ID, 'uncategorized', 'category');
}
}
}
}
//hook in to the publsh_post action to run when a post is published
add_action('publish_post', 'remove_default_category', 10, 2);
Another method is to install this site-specific plugin which contains the same code – https://gist.github.com/kevinlisota/75b3264f7b91e88540d8/archive/3e696ce05c6568de2dcbaa0599a06c19286a4033.zip.
I hope this helps!