I have a custom post type called "Country Story". The title of which will be the name of the country. I want Wordpress to automatically create a new taxonomy called "country" of the same name, i.e. a Country Story called Thailand is created, so I want WP to create a Country taxonomy called Thailand as well. The Country taxonomy already setup. I have the code below so far. It does what I want except I don't know how to get the title during the action hook for publishing the post to pass on to the $cat variable. Can anyone help?
function add_country_category_automatically($post_ID) {
global $wpdb;
if(!has_term('','country',$post_ID)){
$cat = "get title of Country Story published to pass on to Country category";
wp_set_object_terms($post_ID, $cat, 'country');
}
}
add_action('publish_country-story', 'add_country_category_automatically');