in my exemple, “CPT” stands for the slug of your custom post type.
First step :
Using the link of “create new CPT” to add the information of category. for exemple the result would look like http://server/wp-admin/post-new.php?post_type=CPT&category=potatoes
Second step :
Using the hook save_post_CPT
to preset the category. it would be something like that :
add_action("save_post_CPT", function ($post_ID, $post, $update) {
if ($update) {
// it's not a new object
return;
}
if (!isset($_GET["category"])) {
return;
}
// setting the category
wp_set_object_terms($post_ID, $_GET["category"], "category", TRUE);
}, 10, 3);